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

Allow adding fields from user info #44

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions assets/cla/consent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@
email: [email protected]
- name: Riccardo Piola
email: [email protected]
- name: Martin Wallgren
email: [email protected]
- name: Nick Gregory
email: [email protected]
9 changes: 8 additions & 1 deletion pkg/idp/oauth/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
jwtlib "github.com/golang-jwt/jwt/v4"
"github.com/greenpau/go-authcrunch/pkg/errors"
"github.com/greenpau/go-authcrunch/pkg/kms"
"go.uber.org/zap"
"strings"
)

Expand Down Expand Up @@ -96,8 +97,14 @@ func (b *IdentityProvider) validateAccessToken(state string, data map[string]int
return nil, errors.ErrIdentityProviderOAuthEmailNotFound.WithArgs(b.config.IdentityTokenName)
}
}

m := make(map[string]interface{})
for k, v := range claims {
if _, exists := b.userInfoFields[k]; exists {
Copy link
Owner

Choose a reason for hiding this comment

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

@MartinWallgren , thank you for the contribution. What is the effect of this? Is it possible to only add "select" fields as opposed to everything?

b.logger.Debug("Add user info field.", zap.String(k, fmt.Sprintf("%v", v)))
m[k] = v
}
}

for _, k := range tokenFields {
if _, exists := claims[k]; !exists {
continue
Expand Down