-
Notifications
You must be signed in to change notification settings - Fork 259
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
Multi Auth is not honored in flutter #2094
Comments
FYI . I am using transformer v1 |
sounds the issue related to #1566 even though I am not using list of users. but the schema in the schema portal doesnt have (subID: String) for Oncreate , Onupdate and Ondelete . |
Hi @yazoonic thanks for reporting this issue. Looking at the error message:
It indicate that in the GraphQL schema deployed to AppSync,
I've found a similar issue aws-amplify/amplify-codegen#117 it suggests that this issue may be Transformer v1 exclusive. Please consider to migrate to Transformer V2 see if this issue persists, as V1 is not being supported and missing new features. |
Thank you @HuiSF . Why transformer v1 is not supported? At least you guys should remove the limitations on transformer v2 before putting transformver v1 eos. Now O have production and I cant migrate easily because I have tables connected together in non scalar field which I cant migrate at this point .. Btw, I am trying to use multi auth to migrate to owner auth because of the issue I raised on June about selective sync which is not working on Android devices |
comment WIP |
@HuiSF this is the schema on the portal do you want me to check schema in different place? |
Hi @yazoonic sorry I spoke too soon in my previous comment. I dug a bit deeper. There is major difference between transformer v1 and v2 is that the rule
With lunch of the Transformer V2, the library started to supply required auth information when establish subscription, e.g. |
I am ok to migrate to v2 but you have to fix nested tables with non scalar field Also can you check #1816 I want to resolve one of them at least |
Can you explain more with schema examples? |
I removed fields just for simplicity but this how it looks like currently. type Table1 @model @auth(rules: [ { allow: owner,ownerField: "subID", identityClaim: "sub"},{ allow: private}]) { } type table2 @model @auth(rules: [ { allow: owner,ownerField: "subID", identityClaim: "sub"},{ allow: private}]) { |
Can you tell me what's the issue you are having with the schema? @yazoonic |
@HuiSF I am trying to convert this to v2 so table 1 hasMany and table2 category2 field belongs to table 1 this was at the beginning of amplify .. this table cant be migrated to v2 the way I need it to work and it crash my app... I have other nested tables created after and it has automatic field like connectionID that can be migrated without any problems |
OK @yazoonic have you followed the migration document?
Migration process varies according to schema and its use cases. Please provide detailed information so we can help you triage, thanks :) |
yes I did |
@HuiSF I have migrated my dev to v2 and I worked around my tables above in my code. feel free to close this ... but I hope that when transformer v3 released, eos will not happen to transformer v2 :D just question before you close , so now since I have owner auth, I dont need the selective sync that I was using based on subID.. right? |
The owner auth rule will prevent syncing records that don't belong to the owner defined by |
Ok thanks |
Closing this issue, please feel free to reopen and follow up if anything! |
We are also seeing this on v2 |
Description
When you configure your API schemas with multi auth (i.e. owner with custom field name and Private)
when you generate models you will see something like this
modelSchemaDefinition.authRules = [
AuthRule(
authStrategy: AuthStrategy.OWNER,
ownerField: "subID",
identityClaim: "cognito:username",
provider: AuthRuleProvider.USERPOOLS,
operations: [
ModelOperation.CREATE,
ModelOperation.UPDATE,
ModelOperation.DELETE,
ModelOperation.READ
]),
AuthRule(
authStrategy: AuthStrategy.PRIVATE,
operations: [
ModelOperation.CREATE,
ModelOperation.UPDATE,
ModelOperation.DELETE,
ModelOperation.READ
])
];
Now this will fail under Caused by: GraphQLResponseException{message=Subscription error for Entries: [GraphQLResponse.Error{message='Validation error of type UnknownArgument: Unknown field argument subID @ 'onDeleteEntries'', locations='null', path='null', extensions='null'}], errors=[GraphQLResponse.Error{message='Validation error of type UnknownArgument: Unknown field argument subID @ 'onDeleteEntries'', locations='null', path='null', extensions='null'}], recoverySuggestion=See attached list of GraphQLResponse.Error objects.}
samething with oncreate and onupdate
if you remove the owner authfield from the code above, it will work..
The strange part is, this is working on native code (ios at least ) but in flutter it is failing for ios and android.
Categories
Steps to Reproduce
configure your schema with multi auth as below
type Entries @model @auth(rules: [ { allow: owner,ownerField: "subID"},{ allow: private}]) {
push and generate code models
you will get something like this in Entries.dart
modelSchemaDefinition.authRules = [
AuthRule(
authStrategy: AuthStrategy.OWNER,
ownerField: "subID",
identityClaim: "cognito:username",
provider: AuthRuleProvider.USERPOOLS,
operations: [
ModelOperation.CREATE,
ModelOperation.UPDATE,
ModelOperation.DELETE,
ModelOperation.READ
]),
AuthRule(
authStrategy: AuthStrategy.PRIVATE,
operations: [
ModelOperation.CREATE,
ModelOperation.UPDATE,
ModelOperation.DELETE,
ModelOperation.READ
])
];
this will not work, if you remove Owner from the code above it will work..
if you push the scehma with type Entries @model @auth(rules: [ { allow: owner,ownerField: "subID"}]) {
this will work completely fine with owner alone.
I am toward an issue with CLI itself and generate code models .. but this needs more investigation.
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 31
Environment
Dependencies
Device
Pixel XL, iphone xs max
OS
ios 15.5, android 10
Deployment Method
Amplify CLI
CLI Version
9.2.1
Additional Context
No response
Amplify Config
const amplifyconfig = ''' {
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"": {
"endpointType": "GraphQL",
"endpoint":
"region": "us-east-1",
"authorizationType": "AMAZON_COGNITO_USER_POOLS"
}
}
}
},
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"UserAgent": "aws-amplify-cli/0.1.0",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId":
"Region": "us-east-1"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId":
"AppClientId":
"AppClientSecret":
"Region": "us-east-1"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH",
"socialProviders": [],
"usernameAttributes": [
"EMAIL"
],
"signupAttributes": [
"EMAIL"
],
"passwordProtectionSettings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"mfaConfiguration": "OFF",
"mfaTypes": [
"SMS"
],
"verificationMechanisms": [
"EMAIL"
]
}
},
"AppSync": {
"Default": {
"ApiUrl":
"Region": "us-east-1",
"AuthMode": "AMAZON_COGNITO_USER_POOLS",
"ClientDatabasePrefix":
},
"walletin_AWS_IAM": {
"ApiUrl":
"Region": "us-east-1",
"AuthMode": "AWS_IAM",
"ClientDatabasePrefix":
}
}
}
}
}
}''';
The text was updated successfully, but these errors were encountered: