SCIM: Update authinfoquery (#103123)

* Rewrite mismatched externalUID error message

* Update AuhtInfo if user exists
This commit is contained in:
linoman
2025-03-31 22:42:07 +02:00
committed by GitHub
parent 5ef9533751
commit d82d03a1d3
3 changed files with 16 additions and 9 deletions
@@ -48,7 +48,7 @@ var (
)
errMismatchedExternalUID = errutil.Unauthorized(
"user.sync.mismatched-externalUID",
errutil.WithPublicMessage("Mismatched externalUID"),
errutil.WithPublicMessage("Mismatched provisioned identity"),
)
errEmptyExternalUID = errutil.Unauthorized(
"user.sync.empty-externalUID",
@@ -134,6 +134,11 @@ func (s *UserSync) SyncUserHook(ctx context.Context, id *authn.Identity, _ *auth
}
}
if usr.IsProvisioned && id.ExternalUID != userAuth.ExternalUID {
s.log.Error("mismatched externalUID", "provisioned_externalUID", userAuth.ExternalUID, "identity_externalUID", id.ExternalUID)
return errMismatchedExternalUID.Errorf("externalUID mistmatch")
}
syncUserToIdentity(usr, id)
return nil
}
+5 -4
View File
@@ -151,10 +151,11 @@ func (s *Store) SetAuthInfo(ctx context.Context, cmd *login.SetAuthInfoCommand)
func (s *Store) UpdateAuthInfo(ctx context.Context, cmd *login.UpdateAuthInfoCommand) error {
authUser := &login.UserAuth{
UserId: cmd.UserId,
AuthModule: cmd.AuthModule,
AuthId: cmd.AuthId,
Created: GetTime(),
UserId: cmd.UserId,
AuthModule: cmd.AuthModule,
AuthId: cmd.AuthId,
Created: GetTime(),
ExternalUID: cmd.ExternalUID,
}
if cmd.OAuthToken != nil {
+5 -4
View File
@@ -81,10 +81,11 @@ type SetAuthInfoCommand struct {
}
type UpdateAuthInfoCommand struct {
AuthModule string
AuthId string
UserId int64
OAuthToken *oauth2.Token
AuthModule string
AuthId string
UserId int64
OAuthToken *oauth2.Token
ExternalUID string
}
type DeleteAuthInfoCommand struct {