@auth with multiple auth types on nested types not working
See original GitHub issueI have implemented multiple authentication systems with Cognito pools as the default and ‘IAM’ as the other.
I have a city model:
`type City @model
@key(name: "cityByName", fields: ["title"], queryField: "findCityByName")
@auth(rules: [
{ allow: groups, groups: ["admin"], operations: [update, delete, create] },
{ allow: public, provider: iam, operations: [read] }
])
@searchable {
id: ID!
title: String!
description: String
country: String
continent: String
location: Location
timezoneOffset: Float
currency: String
images: [String]
createdAt: Float!
updatedAt: Float!
}
`
with the nested object type ‘Location’:
type Location { lat: Float lon: Float }
Now if I run the query with IAM as the auth mode, the query gives an error:
message: “Not Authorized to access lat on type Location”
Location is a type and simply outlines the data structure for location, and I cannot apply auth rules to it unless i convert it with the @model directive, which I dont want to do.
If i removed the location fields from the query being called, the data returns just fine.
How am i meant to get the location data if I cannot apply auth rules to the location without adding the @model directive??
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
@auth directives don't apply to nested objects when using ...
Say I have a schema something like this: type Approval { id: ID! approvedAt: DateTime! } type Author @auth( query: { rule: """...
Read more >ASP.NET Core authorization not working for nested roles
I require a user to belong to at least one Active Directory role, depending on which environment the code is deployed to (DEV,STAGING,...
Read more >Authorization and authentication - AWS AppSync
Authorization types. There are five ways you can authorize applications to interact with your AWS AppSync GraphQL API. You specify which authorization type...
Read more >Use additional context in Microsoft Authenticator notifications
Additional context can be targeted to only a single group, which can be dynamic or nested. On-premises synchronized security groups and cloud- ...
Read more >Spring Security 5 - OAuth2 Login - Baeldung
Here we'll create credentials of type “OAuth2 Client ID” for our web application. ... If we're not working with a Spring Boot application, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh I see, I thought we were only allowed to use the @auth directive when using amplify-cli, which it then translates to @aws_iam, etc.
For what it’s worth, I would expect the @auth rule to propagate to nested non-model types by default, but thanks for the workaround for now.
@dubchoi In the above schema, the
type Location
is a part of theschema.graphql
file defined by the annotated schema. Thistype Location
is not generated or overwritten by the CLI and whatever auth rules like@aws_iam
is mentioned out there on this type Location, is passed through as is to the de-compiled schema.