Skip to content

Commit 3601e3f

Browse files
committed
Add ability to request additional claims, introduce short option names for OIDC stuff.
1 parent 5b2ef73 commit 3601e3f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ solves this problem, but specifically for Google as Identity Provider.
1515
oidc-token-ferry [OPTIONS] <patch-kubeconfig | render-go-template | render-json>
1616

1717
OpenID Connect Options:
18-
--issuer-url= IdP Issuer URL to be contacted (default: https://accounts.google.com)
19-
--client-id= Client ID to be used
20-
--client-secret= Client Secret to be used
21-
--redirect-url= Redirect URL to be communicated to the IdP (needs to indicate "out of band") (default: urn:ietf:wg:oauth:2.0:oob)
18+
-u, --issuer-url= IdP Issuer URL to be contacted (default: https://accounts.google.com)
19+
-i, --client-id= Client ID to be used
20+
-s, --client-secret= Client Secret to be used
21+
-r, --redirect-url= Redirect URL to be communicated to the IdP (needs to indicate "out of band") (default: urn:ietf:wg:oauth:2.0:oob)
22+
-c, --claim= Additional claims to be requested
2223

2324
Help Options:
2425
-h, --help Show this help message

pkg/oidc/oidc.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import (
1111
)
1212

1313
type Config struct {
14-
IssuerURL string `long:"issuer-url" description:"IdP Issuer URL to be contacted" default:"https://accounts.google.com"`
15-
ClientID string `long:"client-id" required:"yes" description:"Client ID to be used"`
16-
ClientSecret string `long:"client-secret" required:"yes" description:"Client Secret to be used"`
17-
RedirectURL string `long:"redirect-url" description:"Redirect URL to be communicated to the IdP (needs to indicate \"out of band\")" default:"urn:ietf:wg:oauth:2.0:oob"`
14+
IssuerURL string `short:"u" long:"issuer-url" description:"IdP Issuer URL to be contacted" default:"https://accounts.google.com"`
15+
ClientID string `short:"i" long:"client-id" required:"yes" description:"Client ID to be used"`
16+
ClientSecret string `short:"s" long:"client-secret" required:"yes" description:"Client Secret to be used"`
17+
RedirectURL string `short:"r" long:"redirect-url" description:"Redirect URL to be communicated to the IdP (needs to indicate \"out of band\")" default:"urn:ietf:wg:oauth:2.0:oob"`
18+
Claims []string `short:"c" long:"claim" description:"Additional claims to be requested"`
1819
}
1920

2021
type OIDCFlow struct {
@@ -56,6 +57,10 @@ func NewOpenIDConnectFlow(config *Config) (*OIDCFlow, error) {
5657
Scopes: []string{oidc.ScopeOpenID},
5758
}
5859

60+
if config.Claims != nil {
61+
oauth2Config.Scopes = append(oauth2Config.Scopes, config.Claims...)
62+
}
63+
5964
verifier := provider.Verifier(&oidc.Config{ClientID: config.ClientID})
6065

6166
return &OIDCFlow{

0 commit comments

Comments
 (0)