mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
feat: add email scope to OAuth configuration and update documentation
This commit is contained in:
@@ -152,7 +152,7 @@ func (Member) Init(cmd *cobra.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringSlice("member.oauth.scopes", []string{"openid", "profile"}, "OAuth 2.0 scopes")
|
||||
cmd.PersistentFlags().StringSlice("member.oauth.scopes", []string{"openid", "profile", "email"}, "OAuth 2.0 scopes")
|
||||
if err := viper.BindPFlag("member.oauth.scopes", cmd.PersistentFlags().Lookup("member.oauth.scopes")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/m1k1o/neko/server/pkg/types"
|
||||
)
|
||||
|
||||
@@ -166,6 +168,10 @@ func (service *Service) Complete(ctx context.Context, stateToken, code string) (
|
||||
email = claim(idClaims, "email")
|
||||
}
|
||||
|
||||
if email == "" && (len(config.AdminEmails) > 0 || len(config.UserEmails) > 0) {
|
||||
log.Warn().Msg("OAuth admin_emails/user_emails are configured but the provider did not return an 'email' claim; request the 'email' scope")
|
||||
}
|
||||
|
||||
isAdmin := boolClaim(claims, "isAdmin") || boolClaim(idClaims, "isAdmin")
|
||||
admin := administrator(email, isAdmin, config.AdminEmails)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user