Skip to content

Cognito Id_token not processed when oidc is set to True #385

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

Closed
rohit-nsit08 opened this issue Jul 25, 2018 · 6 comments
Closed

Cognito Id_token not processed when oidc is set to True #385

rohit-nsit08 opened this issue Jul 25, 2018 · 6 comments

Comments

@rohit-nsit08
Copy link

I am trying to use this library with cognito and cognito requires response_type=token and returns both access_token and id_token. Library seems to have hardcoded the response_type for such scenario to be token id_token
https://github.com/darbio/angular-oauth2-oidc/blob/master/angular-oauth2-oidc/src/oauth-service.ts#L955-L957
Is there any workaround to make this work?
Thanks

mpbalmeida added a commit to mpbalmeida/angular-oauth2-oidc that referenced this issue Aug 4, 2018
Check user requestType paramater before apply default responseType. So the user can define the behavior.

Closes: manfredsteyer#385
See: manfredsteyer#385
@gwosty
Copy link

gwosty commented Aug 6, 2018

Just so it's clear to me, in order to make this work for Cognito would you have to set
requestType = 'token'
oicd = true

@jeroenheijmans
Copy link
Collaborator

@gwosty Currently you need to set oidc to false have the library ask for responseType of token. I'm not sure what other side-effects that would have.

In PR #397 a change is proposed that allows you to set responseType on the AuthConfig to override it, regardless of how oidc or requestAccesstoken are set. That PR is still open, but you could of course make your own build with that change included.

So before the PR:

if (this.oidc && this.requestAccessToken) {
    this.responseType = 'id_token token';
} else if (this.oidc && !this.requestAccessToken) {
    this.responseType = 'id_token';
} else {
    this.responseType = 'token';
}

After:

if (this.config.responseType) {
  this.responseType = this.config.responseType;
} else {
  if (this.oidc && this.requestAccessToken) {
      this.responseType = 'id_token token';
  } else if (this.oidc && !this.requestAccessToken) {
      this.responseType = 'id_token';
  } else {
      this.responseType = 'token';
  }
}

PS. You mention "requestType" but I've assumed you meant responseType. If it was intentional then my remarks are probably irrelevant.

@gwosty
Copy link

gwosty commented Aug 6, 2018

Sorry, yes, I meant the responseType. I think the pull request only fixes the call but not the actual saving of the token. In https://manfredsteyer.github.io/angular-oauth2-oidc/docs/injectables/OAuthService.html#source line 1314 we would not process the id_token if oidc is not set to true.

@rohit-nsit08
Copy link
Author

I can confirm that Setting oidc true and handling responseType for cognito works. I was able to see both access token and id token.

@rohit-nsit08
Copy link
Author

@manfredsteyer I can see that the pull request for this is still open. Is it ok that for now, If I import the project in my application and modify the source code for the fix? I believe the license is MIT as mentioned on the npm repository but I can't see any license header on the source file. Please treat this as a written request for your permission.

Thanks,

@manfredsteyer
Copy link
Owner

yes, it's absolutely ok. It's MIT. Will at a license file.

jeroenheijmans pushed a commit to jeroenheijmans/angular-oauth2-oidc that referenced this issue Oct 24, 2018
In manfredsteyer#30 the maintainer @manfredsteyer mentions adding an MIT license, but
in 5b8cbbe it was accidentally removed. In manfredsteyer#385 it was mentioned that
the license should be added back. So that's what we do here!

Fixes manfredsteyer#370
See also manfredsteyer#385
See also manfredsteyer#30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants