Skip to content

Commit c860453

Browse files
committed
Improve reliability generally
1 parent da62b23 commit c860453

5 files changed

Lines changed: 26 additions & 12 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/NetAuth/plugin-okta
33
go 1.12
44

55
require (
6-
github.com/NetAuth/NetAuth v0.1.5-0.20190908061829-d33cf3914de8
6+
github.com/NetAuth/NetAuth v0.1.5-0.20190910041404-507f94268003
77
github.com/NetAuth/Protocol v0.0.0-20190423042654-b6296098bf96
88
github.com/golang/protobuf v1.3.2 // indirect
99
github.com/hashicorp/go-hclog v0.9.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ github.com/NetAuth/NetAuth v0.1.5-0.20190908040708-99f89c21459d h1:iVa8DbFqvzhxP
1212
github.com/NetAuth/NetAuth v0.1.5-0.20190908040708-99f89c21459d/go.mod h1:7RO3RQKSobRoghtojZ8hA/SBylqEGteZ+xhYU/IexC8=
1313
github.com/NetAuth/NetAuth v0.1.5-0.20190908061829-d33cf3914de8 h1:kXkjpX4l8wZvQ6N/EElUKgA2wUbRSTFHAlXFXOE7bWo=
1414
github.com/NetAuth/NetAuth v0.1.5-0.20190908061829-d33cf3914de8/go.mod h1:7RO3RQKSobRoghtojZ8hA/SBylqEGteZ+xhYU/IexC8=
15+
github.com/NetAuth/NetAuth v0.1.5-0.20190910041404-507f94268003 h1:Z3A9fbRGDl/RWHcTOPdZL2PevJgNGjcA8qEF9LTpbnk=
16+
github.com/NetAuth/NetAuth v0.1.5-0.20190910041404-507f94268003/go.mod h1:7RO3RQKSobRoghtojZ8hA/SBylqEGteZ+xhYU/IexC8=
1517
github.com/NetAuth/Protocol v0.0.0-20190121213421-fa32b3772b23/go.mod h1:CO+2Q2H4PqOcK9PO0fBxaZrygsIjTHn3k+f24c+Qmj0=
1618
github.com/NetAuth/Protocol v0.0.0-20190423042654-b6296098bf96 h1:sA8zUayQTmfIbRd98R8KS/AewfohWiwTWt5K+m+dPLk=
1719
github.com/NetAuth/Protocol v0.0.0-20190423042654-b6296098bf96/go.mod h1:CO+2Q2H4PqOcK9PO0fBxaZrygsIjTHn3k+f24c+Qmj0=

impl/entity.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ func (o OktaPlugin) EntityUnlock(e pb.Entity) (pb.Entity, error) {
118118
// EntityDestroy should never be used, deleting users is generally
119119
// bad, but if you must, then this function will ensure that users in
120120
// Okta have also been wiped.
121-
func (o OktaPlugin) EntityDestroy(e pb.Entity) error {
121+
func (o OktaPlugin) EntityDestroy(e pb.Entity) (pb.Entity, error) {
122122
oktaID := getEntityOktaID(e)
123123
if oktaID == "" {
124-
return nil
124+
return e, nil
125125
}
126126

127127
_, err := o.c.User.DeactivateUser(oktaID, nil)
@@ -134,5 +134,5 @@ func (o OktaPlugin) EntityDestroy(e pb.Entity) error {
134134
appLogger.Warn("Failed to delete Okta user", "entity", e.GetID(), "error", err)
135135
}
136136

137-
return nil
137+
return e, nil
138138
}

impl/group.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,29 @@ func (o OktaPlugin) GroupUpdate(g pb.Group) (pb.Group, error) {
6464
// GroupDestroy pushes the destruction of groups to Okta. It is
6565
// recommended to never destroy a group, but if this is desired this
6666
// function will ensure the group is removed in Okta as well.
67-
func (o OktaPlugin) GroupDestroy(g pb.Group) error {
67+
func (o OktaPlugin) GroupDestroy(g pb.Group) (pb.Group, error) {
6868
appLogger.Info("Attempting to remove group from Okta", "group", g.GetName())
6969
oktaID := getGroupOktaID(g)
7070
if oktaID == "" {
71-
return nil
71+
return g, nil
7272
}
73-
resp, err := o.c.Group.DeleteGroup(oktaID)
74-
if err != nil {
75-
appLogger.Warn("Failed to delete Okta Group", "group", g.GetName(), "oktaID", oktaID, "error", err)
73+
74+
// Deleting groups in Okta appears to be very racy, and this
75+
// often leads to groups not actually being deleted. The fix
76+
// is to keep trying to get the group until it goes away since
77+
// that is the only way Okta provides to be sure that a group
78+
// is really gone.
79+
var err error
80+
err = nil
81+
for err == nil {
82+
_, err = o.c.Group.DeleteGroup(oktaID)
83+
if err != nil {
84+
appLogger.Warn("Failed to delete Okta Group", "group", g.GetName(), "oktaID", oktaID, "error", err)
85+
}
86+
87+
_, _, err = o.c.Group.GetGroup(oktaID, nil)
88+
appLogger.Debug("Error after getting group", "error", err)
7689
}
7790

78-
appLogger.Debug("Okta Response", "response", resp)
79-
return nil
91+
return g, nil
8092
}

impl/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func init() {
3030

3131
viper.SetDefault("log.level", "INFO")
3232
appLogger = hclog.New(&hclog.LoggerOptions{
33-
Name: "fail2lock",
33+
Name: "okta",
3434
Level: hclog.LevelFromString(viper.GetString("log.level")),
3535
})
3636
hclog.SetDefault(appLogger)

0 commit comments

Comments
 (0)