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

feat(cognito): implement user pool and user pool client constructs #1615

Merged
merged 8 commits into from
Feb 5, 2019

Conversation

dotxlem
Copy link
Contributor

@dotxlem dotxlem commented Jan 26, 2019

Overview

This PR adds initial support for Cognito User Pools.

UserPool allows selecting the type of sign-in (username vs email, etc) with options consistent with what is presented in the console. UserPool also supports setting alias attributes & auto-verified attributes,
as well as setting Lambda function triggers.

A basic implementation for app clients is implemented in UserPoolClient.

This closes #1576

Todo

  • Verification messages
  • Attribute schema
  • Policies

Pull Request Checklist

  • Testing
    • Unit test added
    • CLI change?: manually run integration tests and paste output as a PR comment
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • [ n/a ] Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

This commit adds initial support for Cognito User Pools.
`UserPool` allows selecting the type of sign-in (username vs email, etc)
with options consistent with what is presented in the console.
`UserPool` also supports setting alias attributes & auto-verified attributes,
as well as setting Lambda function triggers.

A basic implementation of app clients is implemented in `UserPoolClient`.
@dotxlem dotxlem requested a review from a team as a code owner January 26, 2019 02:02
Some formatting & safe traversal changes (trivial).
Replacing `lambda.Function` with `lambda.IFunction`.
Copy link
Contributor

@RomainMuller RomainMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty neat! Thanks for spending the effort!

You'd want to add IUserPool and support the import mechanism, so people can refer to user pools that were defined out-of-app. In that line of thought, you'll want to use the I<resource> interfaces (like lambda.IFunction) whenever possible, to be friendlier to re-use of existing resources. I have updated the references to lambda.Function for you though 😄

Also, it's best to surface all underlying resource attributes through the L2 construct (noted some missing attributes in the detail).

packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts Outdated Show resolved Hide resolved
need to write more tests and confirm the build is still successful
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very impressive and high quality work. Thanks for this!
Would be nice to add a bit of sugar (on top of the existing API) to improve usability if possible.
Copy: @sam-goodwin

this currently replaces the ability to pass lambdas in props; will fix
also still need to write tests to meet coverage threshold
updated docs & added missing tests
tests pass at 85% coverage
@dotxlem
Copy link
Contributor Author

dotxlem commented Jan 31, 2019

@RomainMuller @eladb I believe all the requested changes have been made. Let me know if there's anything I missed!

Copy link
Contributor

@RomainMuller RomainMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Thanks for the hard work!

@RomainMuller RomainMuller merged commit 8e03ed6 into aws:master Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cognito: User pool construct
3 participants