Skip to content

Commit 22b278a

Browse files
authored
Add hints (#44)
1 parent 81c75ee commit 22b278a

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ The available flags are:
7373
--encryption-key string path or url to encryption key in jwks format
7474
--grant-type string grant type
7575
-h, --help help for oauthc
76+
--id-token-hint string id token hint
77+
--idp-hint string identity provider hint
7678
--insecure allow insecure connections
79+
--login-hint string user identifier hint
7780
--par enable pushed authorization requests (PAR)
7881
--password string resource owner password credentials grant flow password
7982
--pkce enable proof key for code exchange (PKCE)

cmd/oauth2.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ func NewOAuth2Cmd() (cmd *OAuth2Cmd) {
6666
cmd.PersistentFlags().StringVar(&cconfig.SubjectTokenType, "subject-token-type", "", "third party token type")
6767
cmd.PersistentFlags().StringVar(&cconfig.ActorToken, "actor-token", "", "acting party token")
6868
cmd.PersistentFlags().StringVar(&cconfig.ActorTokenType, "actor-token-type", "", "acting party token type")
69+
cmd.PersistentFlags().StringVar(&cconfig.IDTokenHint, "id-token-hint", "", "id token hint")
70+
cmd.PersistentFlags().StringVar(&cconfig.LoginHint, "login-hint", "", "user identifier hint")
71+
cmd.PersistentFlags().StringVar(&cconfig.IDPHint, "idp-hint", "", "identity provider hint")
6972
cmd.PersistentFlags().StringVar(&cconfig.TLSCert, "tls-cert", "", "path to tls cert pem file")
7073
cmd.PersistentFlags().StringVar(&cconfig.TLSKey, "tls-key", "", "path to tls key pem file")
7174
cmd.PersistentFlags().StringVar(&cconfig.TLSRootCA, "tls-root-ca", "", "path to tls root ca pem file")

internal/oauth2/oauth2.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ type ClientConfig struct {
7777
SubjectTokenType string
7878
ActorToken string
7979
ActorTokenType string
80+
IDTokenHint string
81+
LoginHint string
82+
IDPHint string
8083
TLSCert string
8184
TLSKey string
8285
TLSRootCA string

internal/oauth2/request.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ func (r *Request) AuthorizeRequest(
5050
r.Form.Set("scope", strings.Join(cconfig.Scopes, " "))
5151
}
5252

53+
if cconfig.IDTokenHint != "" {
54+
r.Form.Set("id_token_hint", cconfig.IDTokenHint)
55+
}
56+
57+
if cconfig.LoginHint != "" {
58+
r.Form.Set("login_hint", cconfig.LoginHint)
59+
}
60+
61+
if cconfig.IDPHint != "" {
62+
r.Form.Set("idp_hint", cconfig.IDPHint)
63+
}
64+
5365
if cconfig.PKCE {
5466
codeVerifier = RandomString(CodeVerifierLength)
5567

0 commit comments

Comments
 (0)