Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for service accounts to provider auth #690

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/clients/frontegg_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,20 @@ func getToken(ctx context.Context, password string, endpoint string) (string, st

email, ok := claims["email"].(string)
if !ok {
return "", "", time.Time{}, errors.New("email claim not found in token")
email = ""
// If email is not present (service account case), use metadata.user or sub as identifier
if metadata, hasMetadata := claims["metadata"].(map[string]interface{}); hasMetadata {
if user, hasUser := metadata["user"].(string); hasUser {
email = user
}
}
if email == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is email guaranteed to be an empty string when claims["email"] doesn't return ok as true? If not, wondering if we should add an email = "" right before if metadata, hasMetadata := claims["metadata"].(map[string]interface{}); hasMetadata {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, this is a good point! Thanks Jun!

if sub, hasSub := claims["sub"].(string); hasSub {
email = sub
} else {
return "", "", time.Time{}, errors.New("neither email nor subject found in token")
}
}
}

var tokenExpiry time.Time
Expand Down
Loading