mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Added audience override for token sent to authorization server
This commit is contained in:
parent
20ba7bc735
commit
c67c6f75a2
3 changed files with 12 additions and 3 deletions
|
|
@ -45,6 +45,7 @@ type TokenOptions struct {
|
||||||
Forwarding bool `yaml:"forwarding"`
|
Forwarding bool `yaml:"forwarding"`
|
||||||
Refresh bool `yaml:"refresh"`
|
Refresh bool `yaml:"refresh"`
|
||||||
Scope []string `yaml:"scope"`
|
Scope []string `yaml:"scope"`
|
||||||
|
//TODO: allow specifying audience in returned token
|
||||||
}
|
}
|
||||||
|
|
||||||
type Authentication struct {
|
type Authentication struct {
|
||||||
|
|
@ -55,9 +56,10 @@ type Authentication struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Authorization struct {
|
type Authorization struct {
|
||||||
|
Token TokenOptions `yaml:"token"`
|
||||||
Endpoints Endpoints `yaml:"endpoints"`
|
Endpoints Endpoints `yaml:"endpoints"`
|
||||||
KeyPath string `yaml:"key-path"`
|
KeyPath string `yaml:"key-path"`
|
||||||
Token TokenOptions `yaml:"token"`
|
Audience []string `yaml:"audience"` // NOTE: overrides the "aud" claim in token sent to authorization server
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ type JwtBearerFlowParams struct {
|
||||||
// IdentityProvider *oidc.IdentityProvider
|
// IdentityProvider *oidc.IdentityProvider
|
||||||
TrustedIssuer *oauth.TrustedIssuer
|
TrustedIssuer *oauth.TrustedIssuer
|
||||||
Client *oauth.Client
|
Client *oauth.Client
|
||||||
|
Audience []string
|
||||||
Refresh bool
|
Refresh bool
|
||||||
Verbose bool
|
Verbose bool
|
||||||
KeyPath string
|
KeyPath string
|
||||||
|
|
@ -143,6 +144,11 @@ func NewJwtBearerFlow(eps JwtBearerFlowEndpoints, params JwtBearerFlowParams) (s
|
||||||
payload["exp"] = time.Now().Add(time.Second * 3600 * 16).Unix()
|
payload["exp"] = time.Now().Add(time.Second * 3600 * 16).Unix()
|
||||||
payload["sub"] = "opaal"
|
payload["sub"] = "opaal"
|
||||||
|
|
||||||
|
// if an "audience" value is set, then override the token endpoint value
|
||||||
|
if len(params.Audience) > 0 {
|
||||||
|
payload["aud"] = params.Audience
|
||||||
|
}
|
||||||
|
|
||||||
// include the offline_access scope if refresh tokens are enabled
|
// include the offline_access scope if refresh tokens are enabled
|
||||||
if params.Refresh {
|
if params.Refresh {
|
||||||
v, ok := payload["scope"]
|
v, ok := payload["scope"]
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ func Login(config *Config) error {
|
||||||
},
|
},
|
||||||
Verbose: config.Options.Verbose,
|
Verbose: config.Options.Verbose,
|
||||||
Refresh: config.Authorization.Token.Refresh,
|
Refresh: config.Authorization.Token.Refresh,
|
||||||
|
Audience: config.Authorization.Audience,
|
||||||
},
|
},
|
||||||
ClientCredentialsEndpoints: flows.ClientCredentialsFlowEndpoints{
|
ClientCredentialsEndpoints: flows.ClientCredentialsFlowEndpoints{
|
||||||
Clients: config.Authorization.Endpoints.Clients,
|
Clients: config.Authorization.Endpoints.Clients,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue