Skip to content

Commit

Permalink
feat: Auth refactor to use cdk, eliminate EJS, overrides functionality (
Browse files Browse the repository at this point in the history
aws-amplify#8355)

* feat: add auth override

* fix: auth state unit tests working

* feat: auth e2e fixes and migration e2e included

* fix: fixes package name

* fix: unit tests fix

* fix: unit tests

* fix: fixing overwritten files

* fix: added vm2 and addressed comments

* fix: minor fixes and e2e test for overrides

* fix: cli-core unit test

* fix: userPool group unit test

* fix: minor refractor and comments

* chore: lgtm warnings

* fix: minor fixes

* fix: unit tests
  • Loading branch information
akshbhu authored and jhockett committed Nov 3, 2021
1 parent 3a7dfe9 commit b38a127
Show file tree
Hide file tree
Showing 136 changed files with 8,877 additions and 2,665 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ module.exports = {
'/packages/amplify-provider-awscloudformation/lib',
'/packages/amplify-console-integration-tests/lib',
'/packages/amplify-cli-overrides-helper/lib',
'/packages/amplify-category-auth/resources/auth-custom-resource',

// Ignore CHANGELOG.md files
'/packages/*/CHANGELOG.md',
Expand Down
1,681 changes: 0 additions & 1,681 deletions packages/amplify-category-auth/CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/amplify-category-auth/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

The current set of commands supported by the Amplify Auth Category Plugin

| Command | Description |
| --- | --- |
| amplify auth add | Takes you through steps in the CLI to add an Auth resource to your backend. |
| amplify auth push | Provisions only Auth cloud resources with the latest local developments. |
| Command | Description |
| ------------------- | --------------------------------------------------------------------------------------------------------------- |
| amplify auth add | Takes you through steps in the CLI to add an Auth resource to your backend. |
| amplify auth push | Provisions only Auth cloud resources with the latest local developments. |
| amplify auth remove | Removes Auth resource from your local backend. The resource is removed from the cloud on the next push command. |
2 changes: 1 addition & 1 deletion packages/amplify-category-auth/amplify-plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth",
"type": "category",
"commands": ["add", "console", "enable", "import", "push", "remove", "update", "help"],
"commands": ["add", "console", "enable", "import", "push", "remove", "update", "help", "override"],
"eventHandlers": []
}
10 changes: 6 additions & 4 deletions packages/amplify-category-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-auth",
"version": "2.38.4",
"name": "@aws-amplify/amplify-category-auth",
"version": "1.0.0",
"description": "amplify-cli authentication plugin",
"repository": {
"type": "git",
Expand All @@ -20,7 +20,8 @@
"watch": "tsc -w",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"test": "jest",
"test-watch": "jest --watch"
"test-watch": "jest --watch",
"generateSchemas": "ts-node ./scripts/generateAuthSchemas.ts"
},
"dependencies": {
"amplify-cli-core": "1.31.1",
Expand All @@ -38,7 +39,8 @@
"mime-types": "^2.1.26",
"ora": "^4.0.3",
"promise-sequential": "^1.1.1",
"uuid": "^3.4.0"
"uuid": "^3.4.0",
"vm2": "^3.9.3"
},
"devDependencies": {
"rimraf": "^3.0.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"key": "REDIRECTURL",
"value": "askUser",
"question": {
"name" : "REDIRECTURL",
"name": "REDIRECTURL",
"type": "input",
"message": "Enter the URL that your users will be redirected to upon account confirmation:"
}
Expand All @@ -20,7 +20,7 @@
"key": "EMAILSUBJECT",
"value": "askUser",
"question": {
"name" : "EMAILSUBJECT",
"name": "EMAILSUBJECT",
"type": "input",
"message": "Enter the subject for your custom account confirmation email:"
}
Expand All @@ -29,7 +29,7 @@
"key": "EMAILMESSAGE",
"value": "askUser",
"question": {
"name" : "EMAILMESSAGE",
"name": "EMAILMESSAGE",
"type": "input",
"message": "Enter the body text for your custom account confirmation email (this will appear before the link URL):"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta charset="UTF-8" />
<title>AWS SDK for JavaScript - Browser Getting Started Application</title>
<link rel="stylesheet" type="text/css" href="style.css">

<link rel="stylesheet" type="text/css" href="style.css" />
</head>


<body>
<div>
Expand All @@ -16,9 +14,9 @@
<script src="./spinner.js" type="text/javascript"></script>
<script src="./verify.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {
confirm();
};
window.onload = function () {
confirm();
};
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
var __assign =
(this && this.__assign) ||
function() {
function () {
__assign =
Object.assign ||
function(t) {
function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
Expand Down Expand Up @@ -33,7 +33,7 @@ var defaults = {
shadow: '0 0 1px transparent',
position: 'absolute',
};
var Spinner = /** @class */ (function() {
var Spinner = /** @class */ (function () {
function Spinner(opts) {
if (opts === void 0) {
opts = {};
Expand All @@ -45,7 +45,7 @@ var Spinner = /** @class */ (function() {
* spinning, it is automatically removed from its previous target by calling
* stop() internally.
*/
Spinner.prototype.spin = function(target) {
Spinner.prototype.spin = function (target) {
this.stop();
this.el = document.createElement('div');
this.el.className = this.opts.className;
Expand All @@ -68,7 +68,7 @@ var Spinner = /** @class */ (function() {
* Stops and removes the Spinner.
* Stopped spinners may be reused by calling spin() again.
*/
Spinner.prototype.stop = function() {
Spinner.prototype.stop = function () {
if (this.el) {
if (typeof requestAnimationFrame !== 'undefined') {
cancelAnimationFrame(this.animateId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
@keyframes spinner-line-fade-more {
0%, 100% {
0%,
100% {
opacity: 0; /* minimum opacity */
}
1% {
opacity: 1;
}
}
@keyframes spinner-line-fade-quick {
0%, 39%, 100% {
0%,
39%,
100% {
opacity: 0.25; /* minimum opacity */
}
40% {
opacity: 1;
}
}
@keyframes spinner-line-fade-default {
0%, 100% {
0%,
100% {
opacity: 0.22; /* minimum opacity */
}
1% {
opacity: 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function confirm() {

var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();

cognitoidentityserviceprovider.confirmSignUp(params, function(err, data) {
cognitoidentityserviceprovider.confirmSignUp(params, function (err, data) {
if (err) {
if (err.message === 'User cannot be confirm. Current status is CONFIRMED') {
window.location.replace(redirectUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"region": "us-west-2",
"callerContext": {
"region": "us-west-2",
"callerContext": {
"clientId": "dummyId"
},
"userName": "testUser",
"triggerSource": "CustomMessage_SignUp",
"request": {
},
"userName": "testUser",
"triggerSource": "CustomMessage_SignUp",
"request": {
"codeParameter": "0000"
},
"response": {}
}
},
"response": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"name": "Custom Auth Challenge Scaffolding (Definition)",
"description": "1 of 3 triggers needed to set-up the basic scaffolding for a custom authentication flow. Please note that this scaffolding should be built out using your desired functionality before being used in production."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{

}
{}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"key": "GROUP",
"value": "askUser",
"question": {
"name" : "GROUP",
"name": "GROUP",
"type": "input",
"message": "Enter the name of the group to which users will be added."
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"request": {
"userPoolId": "testID",
"userName": "testUser"
},
"response": {}
}
"request": {
"userPoolId": "testID",
"userName": "testUser"
},
"response": {}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{

}
{}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"request": {
"userAttributes": {
"email": "testEmail@domain.com"
}
},
"response": {}
}
"request": {
"userAttributes": {
"email": "testEmail@domain.com"
}
},
"response": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"value": "askUser",
"private": true,
"question": {
"name" : "RECAPTCHASECRET",
"name": "RECAPTCHASECRET",
"type": "input",
"message": "Enter the Google reCaptcha secret key:"
}
Expand All @@ -19,4 +19,4 @@
"name": "Custom Auth Challenge Scaffolding (Verification)",
"description": "1 of 3 triggers needed to set-up the basic scaffolding for a custom authentication flow. Please note that this scaffolding should be built out using your desired functionality before being used in production."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"name": "Pre Token Generation"
},
"URL": "https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ app.use((req, res, next) => {
// Only perform tasks if the user is in a specific group
const allowedGroup = process.env.GROUP;

const checkGroup = function(req, res, next) {
const checkGroup = function (req, res, next) {
if (req.path == '/signUserOut') {
return next();
}
Expand Down Expand Up @@ -264,10 +264,7 @@ app.post('/signUserOut', async (req, res, next) => {
app.use((err, req, res, next) => {
console.error(err.message);
if (!err.statusCode) err.statusCode = 500; // If err has no specified error code, set error code to 'Internal Server Error (500)'
res
.status(err.statusCode)
.json({ message: err.message })
.end();
res.status(err.statusCode).json({ message: err.message }).end();
});

app.listen(3000, () => {
Expand Down
Loading

0 comments on commit b38a127

Please sign in to comment.