From 1872c6f8153fe7b29362af5b48c7f80abd36729f Mon Sep 17 00:00:00 2001 From: Jeremy Gustie Date: Tue, 3 Mar 2020 15:24:15 -0500 Subject: [PATCH] Use constant audience identifier --- internal/config/config.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 6d189cd63..420865277 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 @@ -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 } @@ -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 } @@ -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