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

Set custom Role(Scope) in AWSCognitoIdentityProvider #1154

Closed
kuchhadiyaa opened this issue Dec 28, 2018 · 11 comments
Closed

Set custom Role(Scope) in AWSCognitoIdentityProvider #1154

kuchhadiyaa opened this issue Dec 28, 2018 · 11 comments
Labels
cognito Issues related to AWS Cognito feature-request Request a new feature service Issues that depend on service/backend work

Comments

@kuchhadiyaa
Copy link

State your question
We are using AWSCognitoIdentityProvider to provide login and signup in our app. We would like to change the spope from "scope": "aws.cognito.signin.user.admin", to "scope": "openid profile"

Currently, there seems no way or changing scopes after or before login.

Which AWS Services are you utilizing?
We are using AWSCognitoIdentityProvider

Provide code snippets (if applicable)
We have tried to update scope after user log in using the following method on AWSCognitoIdentityProvider but it returns an error. though we want to get required scope when a user logs in not after it.

<p>Updates the name and scopes of resource server. All other fields are read-only.</p>
 
 @param request A container for the necessary parameters to execute the UpdateResourceServer service method.
 @param completionHandler The completion handler to call when the load request is complete.
                          `response` - A response object, or `nil` if the request failed.
                          `error` - An error object that indicates why the request failed, or `nil` if the request was successful. On failed execution, `error` may contain an `NSError` with `AWSCognitoIdentityProviderErrorDomain` domain and the following error code: `AWSCognitoIdentityProviderErrorInvalidParameter`, `AWSCognitoIdentityProviderErrorResourceNotFound`, `AWSCognitoIdentityProviderErrorNotAuthorized`, `AWSCognitoIdentityProviderErrorTooManyRequests`, `AWSCognitoIdentityProviderErrorInternalError`.
 
 @see AWSCognitoIdentityProviderUpdateResourceServerRequest
 @see AWSCognitoIdentityProviderUpdateResourceServerResponse
 */
- (void)updateResourceServer:(AWSCognitoIdentityProviderUpdateResourceServerRequest *)request completionHandler:(void (^ _Nullable)(AWSCognitoIdentityProviderUpdateResourceServerResponse * _Nullable response, NSError * _Nullable error))completionHandler;

Environment(please complete the following information):

  • SDK Version: Latest
  • Dependency Manager: Cocoapods
  • Swift Version : 4.1

Device Information (please complete the following information):

  • Device: All
  • iOS Version: All
  • Specific to simulators: No

If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.

@minbi
Copy link
Contributor

minbi commented Dec 28, 2018

Hi @kuchhadiyaa ,

In your case you may want to check App client settings in the Amazon Cognito console for your User Pool. There are checkbox options in the Allowed OAuth Scopes that allow you to add/change the scopes during sign-in.

What is the method call you are using to sign-in users?

@minbi minbi self-assigned this Dec 28, 2018
@minbi minbi added cognito Issues related to AWS Cognito pending-community-response Issue is pending response from the issue requestor labels Dec 28, 2018
@frankmuellr frankmuellr added the question General question label Jan 2, 2019
@kuchhadiyaa
Copy link
Author

Hi @minbi ,

Yes, We already have enabled those settings when we created the pool.

We are using the following method to sign in

userIdentityPool.getUser().getDetails().continueWith(executor: AWSExecutor.mainThread()) {
//Code executed after login
}

and save a closure from the following method to call it when a user does sign in. (AWSCognitoIdentityPasswordAuthentication)

	func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>) {

When a user does sign in we set the result to closure

		let authDetails = AWSCognitoIdentityPasswordAuthenticationDetails(username: self.userName, password: password)
		guard passwordAuthenticationCompletionSource?.trySet(result: authDetails) ?? false else {
			//Unable to set details
			completionSource(false, "Unable to authenticate. Please try again.")
			return
}

@frankmuellr frankmuellr removed the pending-community-response Issue is pending response from the issue requestor label Jan 4, 2019
@minbi
Copy link
Contributor

minbi commented Jan 5, 2019

We will followup with the service team to see which method calls are appropriate.

@kuchhadiyaa
Copy link
Author

@muellerfr any updates on this?

1 similar comment
@kuchhadiyaa
Copy link
Author

@muellerfr any updates on this?

@minbi
Copy link
Contributor

minbi commented Feb 7, 2019

Hi @kuchhadiyaa ,

Currently, specifying custom scopes is only supported via the Oauth client (Cognito Auth SDK) as you have mentioned above. It is not possible to to request custom scopes using the API flow.

I will take this as a feature request to the service team.

@minbi minbi added feature-request Request a new feature and removed question General question labels Feb 7, 2019
@kuchhadiyaa
Copy link
Author

@minbi @nikhil-dabhade Any plan in near future to complete this?

Or do you have any workaround to do this?

Any suggestions are welcome.

@kuchhadiyaa
Copy link
Author

@minbi @nikhil-dabhade Any plan in near future to complete this?

Or do you have any workaround to do this?

@minbi minbi removed their assignment Jun 11, 2019
@adamdabbracci
Copy link

adamdabbracci commented Jul 13, 2019

@minbi @nikhil-dabhade Our API is trying to do just-in-time provisioning through Cognito. Our mobile app logs into Cognito, then sends the access token with each API request. When a user hits our API for the first time, it creates a new user in the database if they haven't already been created. This bug is preventing us from using the access_token from the client to call the userinfo endpoint (which is the OIDC standard way of JIT provisioning), so we have no way of populating the user's information. Additionally, the ID token only contains email and phone and this bug is preventing us from requesting additional info like first and last name, so we can't use that method either.

What is the AWS-recommended way of doing JIT user provisioning into our app when using Cognito as our IDP?

@adamdabbracci
Copy link

@minbi @nikhil-dabhade Is there any plan to update the client to meet OIDC standards? At this point, the access_token generated from this client does not work against the userinfo endpoint, as we cannot use all of the standard OIDC scopes.

@royjit royjit added the service Issues that depend on service/backend work label Sep 23, 2022
@atierian
Copy link
Member

atierian commented Dec 6, 2023

Thanks for opening this feature request. We recommend using Amplify Auth for this -- for more information, please visit https://docs.amplify.aws/swift/build-a-backend/auth/

@atierian atierian closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cognito Issues related to AWS Cognito feature-request Request a new feature service Issues that depend on service/backend work
Projects
None yet
Development

No branches or pull requests

7 participants