Skip to content

GraphQL @auth with Cognito Pool and apiKey does not work #4314

@rlimberger

Description

@rlimberger

Describe the bug
I'm using the following @auth configuration for my GraphQL @model:

@auth (
    rules: [
        { allow: owner },
        { allow: public, provider: apiKey, operations: [read] }
    ]
)

I have setup Amazon Cognito User Pool as primary and apiKey as secondary authorization type:

amplify update api
? Please select from one of the below mentioned services GraphQL
? Choose the default authorization type for the API Amazon Cognito User Pool
Use a Cognito user pool configured as a part of this project.
? Do you want to configure advanced settings for the GraphQL API Yes, I want to make some additional changes.
? Choose the additional authorization types you want to configure for the API (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◯ API key
 ◯ IAM
 ◯ OpenID Connect

When I then run amplify push I get the following error:

@auth directive with 'apiKey' provider found, but the project has no API Key authentication provider configured.

To Reproduce
Annotate your model with:

@auth (
    rules: [
        { allow: owner },
        { allow: private, provider: apiKey, operations: [read] }
    ]
)

Configure both Cognito Pool and apiKey auth providers via Amplify CLI. run amplify push

Expected behavior
Schema should compile and function as expected. Where a Cognito user has full access and an apiKey user has access only to a query.

Version:
Amplify: 3.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    platformIssues tied to the general CLI platformquestionGeneral question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions