Skip to content

Commit

Permalink
Fixed go panic with GitHub provider (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Oct 27, 2023
1 parent ed9d1b2 commit ce8f640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions internal/oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ func oauth2Callback(
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

logger = logger.With(
slog.String("subject", tokens.IDTokenClaims.Subject),
slog.String("preferred_username", tokens.IDTokenClaims.PreferredUsername),
)
if tokens.IDTokenClaims != nil {
logger = logger.With(
slog.String("idtoken.subject", tokens.IDTokenClaims.Subject),
slog.String("idtoken.preferred_username", tokens.IDTokenClaims.PreferredUsername),
)
}

session := state.NewEncoded(encryptedSession)
if err := session.Decode(conf.HTTP.Secret); err != nil {
Expand All @@ -143,6 +145,11 @@ func oauth2Callback(
return
}

logger = logger.With(
slog.String("user.subject", user.Subject),
slog.String("user.preferred_username", user.PreferredUsername),
)

err = provider.OIDC.CheckUser(ctx, session, user, tokens)
if err != nil {
reason := err.Error()
Expand Down
2 changes: 1 addition & 1 deletion internal/oauth2/providers/github/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func (p *Provider) GetEndpoints(conf config.Config) (oauth2.Endpoint, error) {
if !utils.IsURLEmpty(conf.OAuth2.Endpoints.Token) && !utils.IsURLEmpty(conf.OAuth2.Endpoints.Auth) {
if utils.IsURLEmpty(conf.OAuth2.Endpoints.Token) && utils.IsURLEmpty(conf.OAuth2.Endpoints.Auth) {
return github.Endpoint, nil
}

Expand Down

0 comments on commit ce8f640

Please sign in to comment.