Skip to content

Commit 06c9da8

Browse files
committed
Propogate password changes
1 parent a70922d commit 06c9da8

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

impl/entity.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,33 @@ func (o OktaPlugin) EntityDestroy(e pb.Entity) (pb.Entity, error) {
133133

134134
return e, nil
135135
}
136+
137+
// PostSecretChange propogates the secret change directly to Okta via
138+
// an administrative password change. Technically this pushes a
139+
// plaintext password to Okta, and its assumed that Okta will do the
140+
// right thing with it. The alternative is syncing a hash (which is
141+
// antithetical to the core design of netauth) or not syncing the
142+
// change. Given that this is no different from an admin logging in
143+
// and resetting the password, its probably fine.
144+
func (o OktaPlugin) PostSecretChange(e, de pb.Entity) (pb.Entity, error) {
145+
oktaID := getEntityOktaID(e)
146+
if oktaID == "" {
147+
return e, nil
148+
}
149+
150+
p := &okta.PasswordCredential{
151+
Value: de.GetSecret(),
152+
}
153+
uc := &okta.UserCredentials{
154+
Password: p,
155+
}
156+
updatedUser := &okta.User{
157+
Credentials: uc,
158+
}
159+
_, _, err := o.c.User.UpdateUser(oktaID, *updatedUser, nil)
160+
if err != nil {
161+
appLogger.Warn("Error updating Okta user", "error", err)
162+
return e, nil
163+
}
164+
return e, nil
165+
}

0 commit comments

Comments
 (0)