Skip to content

Commit

Permalink
feat: changed type signature (breaking)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngyewch committed Dec 11, 2023
1 parent 6407a6b commit 48617a7
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions adaptor/basic/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type LoginValidator func(email string, password string) (bool, error)

type ClaimsPopulator func(subject string, scope string, claims map[string]interface{}) error
type ClaimsPopulator func(consentRequest *client.OAuth2ConsentRequest, claims map[string]interface{}) error

type Handler struct {
loginValidator LoginValidator
Expand Down Expand Up @@ -43,21 +43,17 @@ func (h *Handler) PopulateClaims(consentRequest *client.OAuth2ConsentRequest, cl
if cp == nil {
cp = DefaultClaimsPopulator
}
for _, scope := range consentRequest.RequestedScope {
err := cp(consentRequest.GetSubject(), scope, claims)
if err != nil {
return err
}
}
return nil
return cp(consentRequest, claims)
}

func DefaultClaimsPopulator(subject string, scope string, claims map[string]interface{}) error {
switch scope {
case "email":
if subject != "" {
claims["email"] = subject
claims["email_verified"] = true
func DefaultClaimsPopulator(consentRequest *client.OAuth2ConsentRequest, claims map[string]interface{}) error {
for _, scope := range consentRequest.RequestedScope {
switch scope {
case "email":
if consentRequest.HasSubject() {
claims["email"] = consentRequest.GetSubject()
claims["email_verified"] = true
}
}
}
return nil
Expand Down

0 comments on commit 48617a7

Please sign in to comment.