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

Reference Auth #2118

Merged
merged 71 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cc14fa2
feat: reference auth basic setup
awsluja Sep 25, 2024
e72d6bc
chore: factory basic tests
awsluja Sep 25, 2024
b1ea919
chore: update api
awsluja Sep 25, 2024
eb664e4
chore: add ref auth package as dependency to backend-auth
awsluja Sep 25, 2024
0a5243d
chore: lint
awsluja Sep 25, 2024
ab370bc
chore: add tests for construct
awsluja Sep 26, 2024
1add05c
chore: cleanup tsconfig
awsluja Sep 26, 2024
f7ca211
chore: add changeset
awsluja Sep 26, 2024
20369c3
Merge branch 'main' into reference-auth
awsluja Sep 26, 2024
4fe3a06
chore: fix tests inputs
awsluja Sep 26, 2024
4d60278
chore: update tests
awsluja Sep 27, 2024
000fd30
fix: update resource provider types
awsluja Sep 30, 2024
4f0998e
Merge branch 'main' into reference-auth
awsluja Sep 30, 2024
52baff2
chore: update api
awsluja Sep 30, 2024
e5c1d07
feat: reference auth outputs
awsluja Oct 2, 2024
da2b152
chore: add tests
awsluja Oct 3, 2024
4efac95
chore: fix test
awsluja Oct 3, 2024
36df254
chore: cleanup reused variables
awsluja Oct 3, 2024
573ef36
Merge branch 'main' into reference-auth
awsluja Oct 3, 2024
22e7ccf
chore: changeset
awsluja Oct 3, 2024
bd984c4
chore: cleanup changeset
awsluja Oct 3, 2024
1bfcfb2
chore: cleanup
awsluja Oct 3, 2024
5b38b6e
chore: cleanup changesets, lockfile, and api
awsluja Oct 3, 2024
b4ccb57
chore: fix mismatched output structure
awsluja Oct 3, 2024
618a0eb
chore: refactor and add tests
awsluja Oct 11, 2024
5075e5c
chore: add more tests for identity pool errors
awsluja Oct 11, 2024
62a6129
chore: cleanup
awsluja Oct 11, 2024
0c3fd28
chore: fix test
awsluja Oct 11, 2024
23649d8
chore: add role tests
awsluja Oct 11, 2024
1f118cd
chore: add tests for user pool client
awsluja Oct 11, 2024
b4a5293
chore: cleanup
awsluja Oct 11, 2024
ae4d34e
chore: refactor
awsluja Oct 12, 2024
6116476
chore: fix api
awsluja Oct 12, 2024
d4358f9
chore: undo changes to concurrent workspace script
awsluja Oct 12, 2024
1d19098
chore: add missing roles permission
awsluja Oct 12, 2024
880bc84
chore: update expected IAM policy permissions for identity pool
awsluja Oct 12, 2024
ebaa8e7
Merge branch 'main' into reference-auth
awsluja Oct 13, 2024
8e5cc68
fix: make sure to throw on errors when using Provider framework
awsluja Oct 14, 2024
cffabc9
chore: refactor
awsluja Oct 14, 2024
1a91132
chore: cleanup
awsluja Oct 14, 2024
3c5f9a9
chore: more cleanup
awsluja Oct 14, 2024
8c14444
chore: check for alias attributes and fix tests
awsluja Oct 15, 2024
2ed2ed2
chore: add support for validating group roles exist for user pool
awsluja Oct 16, 2024
912a5c2
Merge branch 'main' into reference-auth
awsluja Oct 16, 2024
07e33d6
chore: update package-lock file
awsluja Oct 16, 2024
0cccf4b
chore: add checks for oauth validation
awsluja Oct 16, 2024
ee8c52a
chore: fix typo
awsluja Oct 16, 2024
2681a50
chore: eliminate forcing updates on any change
awsluja Oct 16, 2024
97f9427
chore: remove commented out code
awsluja Oct 16, 2024
30866c5
chore: merge factory count into single count for all auth factories
awsluja Oct 16, 2024
e746416
chore: move sample data and npmignore it
awsluja Oct 16, 2024
4156640
chore: cleanup
awsluja Oct 16, 2024
46ad049
chore: fix path
awsluja Oct 16, 2024
f54ebc1
Merge branch 'main' into reference-auth
awsluja Oct 30, 2024
4e876a2
Merge branch 'main' into reference-auth
awsluja Nov 1, 2024
6971eea
chore: update package lock
awsluja Nov 1, 2024
95f8698
Merge branch 'main' into reference-auth
awsluja Nov 5, 2024
cc9d7eb
chore: update package-lock
awsluja Nov 5, 2024
9dcaccd
Merge branch 'main' into reference-auth
awsluja Nov 6, 2024
8083ef1
chore: move construct into backend-auth
awsluja Nov 6, 2024
47c514e
chore: update api
awsluja Nov 6, 2024
8d25476
chore: update changeset
awsluja Nov 6, 2024
555f993
chore: cleanup
awsluja Nov 7, 2024
e1ffd89
chore: move props type to factory
awsluja Nov 7, 2024
703ef45
chore: add working setup for e2e resources in ref auth (#2122)
awsluja Nov 7, 2024
bbacf22
chore: add bsd-3-clause-clear license to allow list
awsluja Nov 8, 2024
8993745
chore: cleanup
awsluja Nov 8, 2024
aeda43a
chore: make lambda deps dev dependencies
awsluja Nov 8, 2024
38661a2
chore: revert license changes
awsluja Nov 8, 2024
4a115f8
chore: remove tag mechanism as not needed for cleanup
awsluja Nov 8, 2024
745d917
Merge branch 'main' into reference-auth
awsluja Nov 11, 2024
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
9 changes: 9 additions & 0 deletions .changeset/good-pugs-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@aws-amplify/auth-construct': minor
'@aws-amplify/backend-auth': minor
'@aws-amplify/backend-data': minor
'@aws-amplify/plugin-types': minor
'@aws-amplify/backend': minor
---

Add support for referenceAuth.
2 changes: 2 additions & 0 deletions .changeset/spicy-rules-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ For local testing we recommend writing unit tests that exercise the code you are
npm run test:dir packages/<package name>/lib/<file-name>.test.ts
```

> Note: If your test depends on \_\_dirname or import.meta.url paths, you may see errors resolving paths if you specify the entire path to the test file. You should specify just the `packages/<package name>` portion of the test you are running.
> Note: You must rebuild using `npm run build` for tests to pick up your changes.
Sometimes it's nice to have a test project to use as a testing environment for local changes. You can create test projects in the `local-testing` directory using
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/auth-construct/src/construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export class AmplifyAuth
userPoolClient,
authenticatedUserIamRole: auth,
unauthenticatedUserIamRole: unAuth,
identityPoolId: identityPool.ref,
cfnResources: {
cfnUserPool,
cfnUserPoolClient,
Expand Down
1 change: 1 addition & 0 deletions packages/backend-auth/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
# Then ignore test js and ts declaration files
*.test.js
*.test.d.ts
**/test-resources/**

# This leaves us with including only js and ts declaration files of functional code
27 changes: 27 additions & 0 deletions packages/backend-auth/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import { AmazonProviderProps } from '@aws-amplify/auth-construct';
import { AmplifyFunction } from '@aws-amplify/plugin-types';
import { AppleProviderProps } from '@aws-amplify/auth-construct';
import { AuthOutput } from '@aws-amplify/backend-output-schemas';
import { AuthProps } from '@aws-amplify/auth-construct';
import { AuthResources } from '@aws-amplify/plugin-types';
import { AuthRoleName } from '@aws-amplify/plugin-types';
import { BackendOutputStorageStrategy } from '@aws-amplify/plugin-types';
import { BackendSecret } from '@aws-amplify/plugin-types';
import { ConstructFactory } from '@aws-amplify/plugin-types';
import { ConstructFactoryGetInstanceProps } from '@aws-amplify/plugin-types';
Expand All @@ -19,6 +21,7 @@ import { FunctionResources } from '@aws-amplify/plugin-types';
import { GoogleProviderProps } from '@aws-amplify/auth-construct';
import { IFunction } from 'aws-cdk-lib/aws-lambda';
import { OidcProviderProps } from '@aws-amplify/auth-construct';
import { ReferenceAuthResources } from '@aws-amplify/plugin-types';
import { ResourceAccessAcceptor } from '@aws-amplify/plugin-types';
import { ResourceAccessAcceptorFactory } from '@aws-amplify/plugin-types';
import { ResourceProvider } from '@aws-amplify/plugin-types';
Expand Down Expand Up @@ -48,6 +51,11 @@ export type AmplifyAuthProps = Expand<Omit<AuthProps, 'outputStorageStrategy' |
};
}>;

// @public (undocumented)
export type AmplifyReferenceAuthProps = Expand<Omit<ReferenceAuthProps, 'outputStorageStrategy'> & {
access?: AuthAccessGenerator;
}>;

// @public
export type AppleProviderFactoryProps = Omit<AppleProviderProps, 'clientId' | 'teamId' | 'keyId' | 'privateKey'> & {
clientId: BackendSecret;
Expand Down Expand Up @@ -86,6 +94,9 @@ export type AuthLoginWithFactoryProps = Omit<AuthProps['loginWith'], 'externalPr
// @public (undocumented)
export type BackendAuth = ResourceProvider<AuthResources> & ResourceAccessAcceptorFactory<AuthRoleName | string> & StackProvider;

// @public (undocumented)
export type BackendReferenceAuth = ResourceProvider<ReferenceAuthResources> & ResourceAccessAcceptorFactory<AuthRoleName | string> & StackProvider;

// @public
export type CustomEmailSender = {
handler: ConstructFactory<AmplifyFunction> | IFunction;
Expand Down Expand Up @@ -130,6 +141,22 @@ export type OidcProviderFactoryProps = Omit<OidcProviderProps, 'clientId' | 'cli
clientSecret: BackendSecret;
};

// @public
export const referenceAuth: (props: AmplifyReferenceAuthProps) => ConstructFactory<BackendReferenceAuth>;

// @public (undocumented)
export type ReferenceAuthProps = {
outputStorageStrategy?: BackendOutputStorageStrategy<AuthOutput>;
userPoolId: string;
identityPoolId: string;
userPoolClientId: string;
authRoleArn: string;
unauthRoleArn: string;
groups?: {
[groupName: string]: string;
};
};

// (No @packageDocumentation comment for this package)

```
7 changes: 6 additions & 1 deletion packages/backend-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
"license": "Apache-2.0",
"dependencies": {
"@aws-amplify/auth-construct": "^1.4.0",
"@aws-amplify/backend-output-schemas": "^1.4.0",
"@aws-amplify/backend-output-storage": "^1.1.3",
"@aws-amplify/plugin-types": "^1.3.1"
},
"devDependencies": {
"@aws-amplify/backend-platform-test-stubs": "^0.3.6",
"@aws-amplify/platform-core": "^1.0.6"
"@aws-amplify/platform-core": "^1.0.6",
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
"@aws-sdk/client-cognito-identity": "^3.624.0",
"@types/aws-lambda": "^8.10.119",
"aws-lambda": "^1.0.7"
},
"peerDependencies": {
"aws-cdk-lib": "^2.158.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-auth/src/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ void describe('AmplifyAuthFactory', () => {
},
new AmplifyUserError('MultipleSingletonResourcesError', {
message:
'Multiple `defineAuth` calls are not allowed within an Amplify backend',
resolution: 'Remove all but one `defineAuth` call',
'Multiple `defineAuth` or `referenceAuth` calls are not allowed within an Amplify backend',
resolution: 'Remove all but one `defineAuth` or `referenceAuth` call',
})
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-auth/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export class AmplifyAuthFactory implements ConstructFactory<BackendAuth> {
if (AmplifyAuthFactory.factoryCount > 0) {
throw new AmplifyUserError('MultipleSingletonResourcesError', {
message:
'Multiple `defineAuth` calls are not allowed within an Amplify backend',
resolution: 'Remove all but one `defineAuth` call',
'Multiple `defineAuth` or `referenceAuth` calls are not allowed within an Amplify backend',
resolution: 'Remove all but one `defineAuth` or `referenceAuth` call',
});
}
AmplifyAuthFactory.factoryCount++;
Expand Down
6 changes: 6 additions & 0 deletions packages/backend-auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export { BackendAuth, AmplifyAuthProps, defineAuth } from './factory.js';
export {
BackendReferenceAuth,
AmplifyReferenceAuthProps,
referenceAuth,
ReferenceAuthProps,
} from './reference_factory.js';
export * from './types.js';
6 changes: 6 additions & 0 deletions packages/backend-auth/src/lambda/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"no-console": "off",
"amplify-backend-rules/prefer-amplify-errors": "off"
}
}
Loading
Loading