coreos / go-oidc

A Go OpenID Connect client.
Apache License 2.0
1.92k stars 393 forks source link

Add Scope value predefined in the specification (profile, email, address, phone) #385

Open arukiidou opened 1 year ago

arukiidou commented 1 year ago

Summary

If I open this PR, is it acceptable?

Citation of specifications

https://openid.net/specs/openid-connect-core-1_0.html

5.4.  Requesting Claims using Scope Values
profile
OPTIONAL. This scope value requests access to the End-User's default profile Claims, which are: name, family_name, given_name, middle_name, nickname, preferred_username, profile, picture, website, gender, birthdate, zoneinfo, locale, and updated_at.
email
OPTIONAL. This scope value requests access to the email and email_verified Claims.
address
OPTIONAL. This scope value requests access to the address Claim.
phone
OPTIONAL. This scope value requests access to the phone_number and phone_number_verified Claims.

Key changes.


const (
    ScopeProfile = "profile"
    ScopeEmail = "email"
    ScopeAddress = "address"
    ScopePhone = "phone"
)

Anticipated Questions

        // before
    config := oauth2.Config{
        Scopes:       []string{oidc.ScopeOpenID, "profile", "email"},
    }
        // after
    config := oauth2.Config{
        Scopes:       []string{oidc.ScopeOpenID, oidc.ScopeProfile, oidc.ScopeEmail},
    }
ericchiang commented 1 year ago

Yeah this sounds reasonable, feel free to send a PR!

arukiidou commented 1 year ago

@ericchiang