Skip to content

Commit f286840

Browse files
authored
fix oauth domain check (#474) (#476)
1 parent edb88b5 commit f286840

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/app/auth/auth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ func (a *Authenticator) OauthLoginStep2(ctx context.Context, providerId, nonce,
434434
return nil, fmt.Errorf("unable to parse user information: %w", err)
435435
}
436436

437+
if !isDomainAllowed(userInfo.Email, oauthProvider.GetAllowedDomains()) {
438+
return nil, fmt.Errorf("user %s is not in allowed domains", userInfo.Email)
439+
}
440+
437441
ctx = domain.SetUserInfo(ctx,
438442
domain.SystemAdminContextUserInfo()) // switch to admin user context to check if user exists
439443
user, err := a.processUserInfo(ctx, userInfo, domain.UserSourceOauth, oauthProvider.GetName(),
@@ -450,10 +454,6 @@ func (a *Authenticator) OauthLoginStep2(ctx context.Context, providerId, nonce,
450454
return nil, fmt.Errorf("unable to process user information: %w", err)
451455
}
452456

453-
if !isDomainAllowed(userInfo.Email, oauthProvider.GetAllowedDomains()) {
454-
return nil, fmt.Errorf("user is not in allowed domains: %w", err)
455-
}
456-
457457
if user.IsLocked() || user.IsDisabled() {
458458
a.bus.Publish(app.TopicAuditLoginFailed, domain.AuditEventWrapper[audit.AuthEvent]{
459459
Ctx: ctx,

0 commit comments

Comments
 (0)