Skip to content

Commit 4fffd0f

Browse files
authored
Merge pull request #1154 from jdoupe/AuthParams
add AuthParams to token
2 parents cc0b543 + 615f8c8 commit 4fffd0f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

command/ca/provisioner/provisioner.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,16 @@ Use the '--group' flag multiple times to configure multiple groups.`,
605605
Name: "tenant-id",
606606
Usage: `The <tenant-id> used to replace the templatized tenantid value in the OpenID Configuration.`,
607607
}
608+
oidcScopeFlag = cli.StringSliceFlag{
609+
Name: "scope",
610+
Usage: `The <scope> list used to validate the scopes extension in an OpenID Connect token.
611+
Use the '--scope' flag multiple times to configure multiple scopes.`,
612+
}
613+
oidcAuthParamFlag = cli.StringSliceFlag{
614+
Name: "auth-param",
615+
Usage: `The <auth-param> list used to validate the auth-params extension in an OpenID Connect token.
616+
Use the '--auth-param' flag multiple times to configure multiple auth-params.`,
617+
}
608618

609619
// X5C provisioner flags
610620
x5cRootsFlag = cli.StringFlag{

command/ca/provisioner/update.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ OIDC
5454
[**--domain**=<domain>] [**--remove-domain**=<domain>]
5555
[**--group**=<group>] [**--remove-group**=<group>]
5656
[**--admin**=<email>]... [**--remove-admin**=<email>]...
57+
[**--scope**=<scope>] [**--remove-scope**=<scope>]
58+
[**--auth-param**=<auth-param>] [**--remove-auth-param**=<auth-param>]
5759
[**--admin-cert**=<file>] [**--admin-key**=<file>]
5860
[**--admin-subject**=<subject>] [**--admin-provisioner**=<name>] [**--admin-password-file**=<file>]
5961
[**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>] [**--ca-config**=<file>]
@@ -123,6 +125,8 @@ SCEP
123125
oidcRemoveDomainFlag,
124126
oidcGroupFlag,
125127
oidcTenantIDFlag,
128+
oidcScopeFlag,
129+
oidcAuthParamFlag,
126130

127131
// X5C Root Flag
128132
x5cRootsFlag,
@@ -802,6 +806,18 @@ func updateOIDCDetails(ctx *cli.Context, p *linkedca.Provisioner) error {
802806
}
803807
details.ConfigurationEndpoint = ce
804808
}
809+
if ctx.IsSet("remove-scope") {
810+
details.Scopes = removeElements(details.Scopes, ctx.StringSlice("remove-scope"))
811+
}
812+
if ctx.IsSet("scope") {
813+
details.Scopes = append(details.Scopes, ctx.StringSlice("scope")...)
814+
}
815+
if ctx.IsSet("remove-auth-param") {
816+
details.AuthParams = removeElements(details.AuthParams, ctx.StringSlice("remove-auth-param"))
817+
}
818+
if ctx.IsSet("auth-param") {
819+
details.AuthParams = append(details.AuthParams, ctx.StringSlice("auth-param")...)
820+
}
805821
return nil
806822
}
807823

utils/cautils/token_generator.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ func generateOIDCToken(ctx *cli.Context, p *provisioner.OIDC) (string, error) {
124124
args := []string{"oauth", "--oidc", "--bare",
125125
"--provider", p.ConfigurationEndpoint,
126126
"--client-id", p.ClientID, "--client-secret", p.ClientSecret}
127+
if len(p.Scopes) != 0 {
128+
for _, keyval := range p.Scopes {
129+
args = append(args, "--scope", keyval)
130+
}
131+
}
132+
if len(p.AuthParams) != 0 {
133+
for _, keyval := range p.AuthParams {
134+
args = append(args, "--auth-param", keyval)
135+
}
136+
}
127137
if ctx.Bool("console") {
128138
args = append(args, "--console")
129139
}

0 commit comments

Comments
 (0)