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

accept responseType as a constructor arg #525

Merged
merged 1 commit into from
Oct 30, 2020

Conversation

aarongranick-okta
Copy link
Contributor

} else {
isCodeResponse = responseType === 'code';
}
return (!this.options.pkce && isCodeResponse);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably wrong, my understanding is authorization code flow is a super set of pkce flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are probably right. we need a way of knowing whether we expect to redirect or not. For us this is web/native apps with "authorization_code" flow who are not using PKCE. Open to suggestions for better naming here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A proper name can be complex, how about

isAuthorizationCodeFlow(pkce?: boolean): boolean 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow the impact of the passed boolean.

If this is checking for an Authorization code flow without PKCE, I'd say
isAuthorizationCodeFlowWithoutPKCE() - a little Java-esque, but not confusing

If want to cover both, I'd be more explicit in the param:
isAuthorizationCodeFlow({ withPKCE?: boolean })

  • Ideally withPKCE would be required
  • using the object so that it's clear, as (isAuthorizationCodeFlow(true) is not clear)
  • This still makes it less than perfectly clear what happens if you pass false, which is why I prefer the explicit name above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuowu I don't want to accept arguments, because the point of this method is for AuthJS to tell someone else whether it is operating in (non-PKCE) authorization code flow. Maybe if I had another function isPKCE then the caller can say !isPkce() and isAuthorizationCodeFlow() to get the same meaning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would make sense! our pkce flow actually is pkce + ahthorization code flow,that's where the confusion is introduced, imo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isPkce() and isAuthorizationCodeFlow() - this looks ideal to me.

@@ -430,6 +431,17 @@ class OktaAuthBrowser extends OktaAuthBase implements OktaAuth, SignoutAPI {
const storage = browserStorage.getSessionStorage();
storage.removeItem(REFERRER_PATH_STORAGE_KEY);
}

isAuthorizationCodeFlow(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update changelog and readme if it's a public method

add methods: isPKCE, hasResponseType
@aarongranick-okta aarongranick-okta force-pushed the ag-OKTA-340725-response-type branch from 0192db7 to a649975 Compare October 29, 2020 22:12
@codecov-io
Copy link

codecov-io commented Oct 30, 2020

Codecov Report

Merging #525 into master will increase coverage by 0.22%.
The diff coverage is 95.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #525      +/-   ##
==========================================
+ Coverage   91.28%   91.50%   +0.22%     
==========================================
  Files          32       32              
  Lines        1847     1896      +49     
  Branches      412      424      +12     
==========================================
+ Hits         1686     1735      +49     
  Misses        161      161              
Impacted Files Coverage Δ
lib/browser/browser.ts 94.81% <95.38%> (-0.49%) ⬇️
lib/token.ts 96.10% <100.00%> (+0.29%) ⬆️
lib/util.ts 74.23% <100.00%> (+0.64%) ⬆️
lib/AuthStateManager.ts 91.39% <0.00%> (+2.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b441ee0...a649975. Read the comment docs.

@aarongranick-okta aarongranick-okta merged commit 85f1a24 into master Oct 30, 2020
@aarongranick-okta aarongranick-okta deleted the ag-OKTA-340725-response-type branch October 30, 2020 16:22
brettritter-okta pushed a commit that referenced this pull request Nov 4, 2020
add methods: isPKCE, hasResponseType
brettritter-okta pushed a commit that referenced this pull request Nov 5, 2020
add methods: isPKCE, hasResponseType
brettritter-okta pushed a commit that referenced this pull request Nov 12, 2020
add methods: isPKCE, hasResponseType
eng-prod-CI-bot-okta pushed a commit that referenced this pull request Nov 18, 2020
base pattern for renewTokensWithRefresh
renew successfully (once)
Fixed renewal with refresh token
Adds base revoke for refresh tokens
Updates existing tests to pass
updates docs a bit
feat: add method handleLoginRedirect (#528)
accept responseType as a constructor arg (#525)

add methods: isPKCE, hasResponseType
update samples to use authStateManager (#506)
revised to try for non-breaking
Fix for lack of AuthState
Fix return val for renewTokens
Fix responseType on renew error
Fix urls passed for renew
Run e2e tests w/o refresh token for now
prep for 4.2.0 release

OKTA-330344
<<<Jenkins Check-In of Tested SHA: 8f7dfb6 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
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

Successfully merging this pull request may close these issues.

4 participants