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

fix: update auth vnext validation to use private for oidc #8606

Merged
merged 1 commit into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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