-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SaaS Boost API access via OAuth client credentials grant #450
Conversation
runtime. Add the API Gateway invoke URL to the app client secret details so a client doesn't have to make another call to some other service to figure it out.
@@ -846,6 +846,7 @@ Resources: | |||
CustomDomainName: !If [HasSystemIdPCustomDomain, !Ref SystemIdentityProviderDomain, ''] | |||
CustomDomainHostedZone: !If [HasSystemIdPCustomDomain, !Ref SystemIdentityProviderHostedZone, ''] | |||
CustomDomainCertificate: !If [HasSystemIdPCustomDomain, !Ref SystemIdentityProviderCertificate, ''] | |||
ApiGatewayUrl: !Sub https://${core.Outputs.SaaSBoostPublicApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/${PublicApiStage} #!GetAtt publicapi.Outputs.PublicApiGatewayEndpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we just use !GetAtt
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it would make a circular dependency with the saas-boost-public-api.yaml stack
Properties: | ||
LogGroupName: !Sub /aws/lambda/sb-${Environment}-cognito-client-details | ||
RetentionInDays: 30 | ||
CognitoAppClientDetailsExecRole: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need Condition: UseCognito
for this, since we refer to UserPool
in the cognito-idp
Allow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! Excited to see what we can do with automated testing using this change.
When we upgraded the System User Service to use OAuth
authorization_code
grant for access to the SaaS Boost API instead of Amazon Cognito native authorization, we removed the lesser-known private API/token
endpoint that returned anIdentity Token
for the SaaS Boost admin user.This PR generates an application client with a secret to be used for
client_credentials
grant against the SaaS Boost API. It will return anAccess Token
with the equivalent permissions as the SaaS Boost admin user. This token can be used as a bearer token for any of the public SaaS Boost API resources.The client's details are stored in Secrets Manager at
/saas-boost/${ENVIRONMENT}/API_APP_CLIENT
. Any client code wanting to perform computer-to-computer invocation of the SaaS Boost API will need to be given explicit allow permissions via IAM to access that secret.DO NOT use this secret in a public client such as a JavaScript web app or a mobile application. This should only be used in backend server side code that is authorized.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license