Skip to content

Commit

Permalink
fix: update auth vnext validation to use private for oidc (aws-amplif…
Browse files Browse the repository at this point in the history
  • Loading branch information
SwaySway authored and AmmarKarachi committed Nov 3, 2021
1 parent 2475dbd commit 824b182
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ describe('schema generation directive tests', () => {
expectMultiple(tagType, expectedDirectiveNames);
});

test('OIDC works with private', () => {
const cognitoUserPoolAndOidcAuthRules =
'@auth(rules: [ { allow: private, provider: oidc, operations: [read] } { allow: owner, ownerField: "editors" } { allow: groups, groupsField: "groups"} ])';
const authConfig = withAuthModes(apiKeyDefaultConfig, ['AMAZON_COGNITO_USER_POOLS', 'OPENID_CONNECT']);

(authConfig.additionalAuthenticationProviders[1] as AppSyncAuthConfigurationOIDCEntry).openIDConnectConfig = {
name: 'Test Provider',
issuerUrl: 'https://abc.def/',
};
transformTest(cognitoUserPoolAndOidcAuthRules, authConfig, [userPoolsDirectiveName, openIdDirectiveName]);
});

test(`Nested types without @model getting directives applied (cognito default, api key additional)`, () => {
const schema = getSchemaWithNonModelField(privateAndPublicDirective);
const transformer = getTransformer(withAuthModes(userPoolsDefaultConfig, ['API_KEY']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ found '${rule.provider}' assigned.`,
// Private
//
if (rule.allow === 'private') {
if (rule.provider !== null && rule.provider !== 'userPools' && rule.provider !== 'iam') {
if (rule.provider !== null && rule.provider !== 'userPools' && rule.provider !== 'iam' && rule.provider !== 'oidc') {
throw new InvalidDirectiveError(
`@auth directive with 'private' strategy only supports 'userPools' (default) and 'iam' providers, but \
found '${rule.provider}' assigned.`,
Expand Down

0 comments on commit 824b182

Please sign in to comment.