Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from redskyops/audience
Browse files Browse the repository at this point in the history
Use constant audience identifier
  • Loading branch information
jgustie authored Mar 4, 2020
2 parents 64d60ab + 1872c6f commit 554edd0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import (
"golang.org/x/oauth2/clientcredentials"
)

// audience is the logical identifier of the Red Sky API
const audience = "https://api.carbonrelay.io/v1/"

// Loader is used to initially populate a Red Sky configuration
type Loader func(cfg *RedSkyConfig) error

Expand Down Expand Up @@ -306,7 +309,7 @@ func (rsc *RedSkyConfig) NewAuthorization() (*authorizationcode.Config, error) {
c.Endpoint.AuthURL = srv.Authorization.AuthorizationEndpoint
c.Endpoint.TokenURL = srv.Authorization.TokenEndpoint
c.Endpoint.AuthStyle = oauth2.AuthStyleInParams
c.EndpointParams = map[string][]string{"audience": {srv.Identifier}}
c.EndpointParams = map[string][]string{"audience": {audience}}
return c, nil
}

Expand All @@ -324,7 +327,7 @@ func (rsc *RedSkyConfig) NewDeviceAuthorization() (*devicecode.Config, error) {
AuthStyle: oauth2.AuthStyleInParams,
},
DeviceAuthorizationURL: srv.Authorization.DeviceAuthorizationEndpoint,
EndpointParams: map[string][]string{"audience": {srv.Identifier}},
EndpointParams: map[string][]string{"audience": {audience}},
}, nil
}

Expand Down Expand Up @@ -362,7 +365,7 @@ func (rsc *RedSkyConfig) tokenSource(ctx context.Context) (oauth2.TokenSource, e
ClientID: az.Credential.ClientID,
ClientSecret: az.Credential.ClientSecret,
TokenURL: srv.Authorization.TokenEndpoint,
EndpointParams: url.Values{"audience": []string{srv.Identifier}},
EndpointParams: url.Values{"audience": []string{audience}},
AuthStyle: oauth2.AuthStyleInParams,
}
return cc.TokenSource(ctx), nil
Expand Down

0 comments on commit 554edd0

Please sign in to comment.