-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: token behavior improvements #1421
Conversation
b6e2d96
to
cd78a16
Compare
Hello Tristan, could you have a look on this PR? We have improved the token handling in the PWA and need some further feedback from you. :) |
Hi @Eisie96 intershop-pwa/src/app/core/services/token/token.service.ts Lines 92 to 101 in 11fd815
Won't this invalidate the sso token when this function is called? |
Thank you for your response! The linked function will not fetch an anonymous user token. It will only set the apiToken within the api-token.service.ts to use them for all ICM request. The anonymous user token will only be called, when no apiToken is available (here not the case) and the basket request will be fetched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem with anonymous apiToken cookie from ICM in Hybrid Approach
When switching back from an ICM rendered page in Hybrid Approach where an anonymous apiToken cookie was set without a basket, the PWA tries to fetch the basket for that cookie and fails (REST error).
This results an disabled "Add to Cart" buttons in the whole PWA.
Other than this the rework looks good and worked with SSO and Punchout tests as expected.
cd78a16
to
5a93e0e
Compare
* own service, which is responsible for all token handling with the ICM * rename ICMTokenEndpoint Service to TokenService and moved it files to core/services folder * create utility class to instantiate custom oauthService instance * adapt documentation for new authentication behavior closes: #1374
…oken is available
…t an assigned basket * issue that occurs with the Hybrid Approach * failing basket request needs to reset the loading state
5a93e0e
to
7faf780
Compare
Fixed Hybrid Approach issue that was independent from the token behavior improvements. Had the same problems before. |
PR Type
[ ] Bugfix
[ x ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no API changes)
[ ] Build-related changes
[ ] CI-related changes
[ ] Documentation content changes
[ ] Application / infrastructure changes
[ ] Other:
What Is the Current Behavior?
The new token api is introduced with the PWA version 3.2 (#1156). Since then, we are dealing with some issues, which needed to be addressed.
Issue Number: Closes #1374
What Is the New Behavior?
The
OauthConfigurationService
is replaced by theTokenService
. The service will inject it's own OAuthService instance and is responsible for it's configuration and fetching token mechanism. All identity provider are not relying on the internal ICM token behavior anymore.The anonymous user token behavior is adapted. It will only be fetched, when an anoymous user will create a basket. The functionality is included in the
ApiTokenService
intercept method.Does this PR Introduce a Breaking Change?
The identity provider needs to be adapted. These providers are not responsible anymore to configure the oAuthService for fetching ICM tokens.
When a identity provider needs a OAuthService (e.g. auth0-identity-provider), then it has to inject the dependency with a complete new OAuthService instance. Otherwise it could lead to unnecassary side effects. (e.g. during configuration)
[ x ] Yes
[ ] No
Other Information
AB#85534