Skip to content
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

REST API (API Gateway v1) Cognito User Pool authorizer CF intristic functions #11505

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/plugins/aws/package/compile/events/api-gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ const authorizerSchema = {
managedExternally: { type: 'boolean' },
name: { type: 'string' },
resultTtlInSeconds: { type: 'integer', minimum: 0, maximum: 3600 },
scopes: { type: 'array', items: { type: 'string' } },
scopes: {
type: 'array',
items: {
anyOf: [{ type: 'string' }, { $ref: '#/definitions/awsCfInstruction' }],
},
},
type: {
anyOf: ['token', 'cognito_user_pools', 'request', 'aws_iam', 'custom'].map(
caseInsensitive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,38 @@ describe('#compileMethods()', () => {
).to.not.have.property('AuthorizationScopes');
});

it('should pass on import functions for a cognito user pool authorizer scopes', () => {
awsCompileApigEvents.validated.events = [
{
functionName: 'First',
http: {
authorizer: {
name: 'authorizer',
type: 'COGNITO_USER_POOLS',
authorizerId: { Ref: 'CognitoAuthorizer' },
scopes: [
{
'Fn::ImportValue': 'ImportedScope',
},
],
},
integration: 'AWS',
path: 'users/create',
method: 'post',
},
},
];

awsCompileApigEvents.compileMethods();
const resource =
awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
.ApiGatewayMethodUsersCreatePost;

expect(resource.Properties.AuthorizationScopes[0]).to.deep.equal({
'Fn::ImportValue': 'ImportedScope',
});
});

it('should set claims for a cognito user pool', () => {
awsCompileApigEvents.validated.events = [
{
Expand Down