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

Add PreTokenGeneration & UserMigration Cognito triggers #6511

Merged

Conversation

@v-anton
Copy link

v-anton commented Aug 7, 2019

What did you implement:

Closes #5513

How did you implement it:

Added PreTokenGeneration & UserMigration triggers to the validTriggerSources since CloudFormation already supports it:

const validTriggerSources = [
  'PreSignUp',
  'PostConfirmation',
  'PreAuthentication',
  'PostAuthentication',
  'PreTokenGeneration',
  'CustomMessage',
  'DefineAuthChallenge',
  'CreateAuthChallenge',
  'VerifyAuthChallengeResponse',
  'UserMigration',
];

How can we verify it:

  1. Bootstrap Serverless framework project.
  2. Add the following code to serverless.yml:
service:
  name: testservicename
custom:
  stage: ${opt:stage, 'dev'}
  region: ${opt:region, 'eu-central-1'}
provider:
  name: aws
  runtime: nodejs10.x
  stage: ${self:custom.stage}
  region: ${self:custom.region}
functions:
  user-migration:
    handler: user-migration.handler
    events:
      - cognitoUserPool:
          pool: ${self:service.name}-${self:custom.stage}-user-pool
          trigger: UserMigration
          existing: true
  pre-token-generation:
    handler: pre-token-generation.handler
    events:
      - cognitoUserPool:
          pool: ${self:service.name}-${self:custom.stage}-user-pool
          trigger: PreTokenGeneration
          existing: true
resources:
  Resources:
    CognitoUserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: ${self:service.name}-${self:custom.stage}-user-pool
        UsernameAttributes:
          - email
        AutoVerifiedAttributes:
          - email

    CognitoUserPoolClient:
      Type: AWS::Cognito::UserPoolClient
      Properties:
        ClientName: ${self:service.name}-${self:custom.stage}-user-pool-client
        UserPoolId:
          Ref: CognitoUserPool
        ExplicitAuthFlows: [ADMIN_NO_SRP_AUTH, USER_PASSWORD_AUTH]
        GenerateSecret: false
  1. Deploy the app.
  2. Check if triggers are referenced properly in AWS Cognito User Pool settings.

Todos:

Note: Run npm run test-ci to run all validation checks on proposed changes

  • Write tests and confirm existing functionality is not broken.
    Validate via npm test
  • Write documentation
  • Ensure there are no lint errors.
    Validate via npm run lint-updated
    Note: Some reported issues can be automatically fixed by running npm run lint:fix
  • Ensure introduced changes match Prettier formatting.
    Validate via npm run prettier-check-updated
    Note: All reported issues can be automatically fixed by running npm run prettify-updated
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: NO
Is it a breaking change?: NO

@pmuens pmuens self-assigned this Aug 7, 2019
@pmuens pmuens added this to Engineering - In Development in Serverless via automation Aug 7, 2019
@pmuens pmuens added this to the 1.50.0 milestone Aug 7, 2019
@pmuens
pmuens approved these changes Aug 7, 2019
Copy link
Member

pmuens left a comment

Thanks for working on this @v-anton 👍

I just tested it and it worked fine! LGTM :shipit:

Serverless automation moved this from Engineering - In Development to Reviewer Approved Aug 7, 2019
@pmuens pmuens merged commit 35d1b8b into serverless:master Aug 7, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
security/snyk - package.json (serverless) No manifest changes detected
Serverless automation moved this from Reviewer Approved to Done Aug 7, 2019
@v-anton

This comment has been minimized.

Copy link
Author

v-anton commented Aug 7, 2019

Thanks @pmuens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Serverless
  
Done
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.