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

NAS-132648 / 25.04 / query param handling for auth tokens #11080

Merged
merged 8 commits into from
Dec 5, 2024
Merged

Conversation

aervin
Copy link
Collaborator

@aervin aervin commented Nov 20, 2024

Changes:

Testing:
One method:

  • clear localStorage
  • you'll have to comment out the https: check in AuthService.setQueryToken
  • midclt call auth.generate_token
  • append the token to an app route: localhost:4200/storage/disks?token=<token>

Downstream

Affects Reasoning
Documentation

…e. forward query params on redirect in auth-guard.service
@bugclerk bugclerk changed the title NAS-132648: query param handling for auth tokens NAS-132648 / 25.04 / query param handling for auth tokens Nov 20, 2024
@bugclerk
Copy link
Contributor

@aervin
Copy link
Collaborator Author

aervin commented Nov 20, 2024

The approach so far is to forward query params on redirect to /signin (AuthGuardService:canActivate). From there, add a bit of logic to signin.store and auth.service to handle the token.

However, this isn't working like I'd expect. Seems that WebsocketHandlerService is calling its resetUI method and interfering with the redirect.

image

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.45%. Comparing base (cf486c8) to head (748ebfc).
Report is 54 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/app/core/guards/websocket-connection.guard.ts 0.00% 5 Missing ⚠️
src/app/pages/signin/store/signin.store.ts 84.21% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11080      +/-   ##
==========================================
+ Coverage   82.35%   82.45%   +0.10%     
==========================================
  Files        1630     1648      +18     
  Lines       57229    58008     +779     
  Branches     5915     5957      +42     
==========================================
+ Hits        47130    47833     +703     
- Misses      10099    10175      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

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

Seems to be redirecting fine for me:

2024-11-21.11.03.57.mov

src/app/services/auth/auth.service.ts Outdated Show resolved Hide resolved
@undsoft
Copy link
Collaborator

undsoft commented Nov 21, 2024

BTW, I don't know if tokens in browser history is kosher.

…t connection to the NAS has opened at least once. adds queryToken to signin.store state.
@aervin aervin marked this pull request as ready for review November 25, 2024 14:53
@aervin aervin requested a review from a team as a code owner November 25, 2024 14:53
@aervin aervin requested review from RehanY147 and undsoft and removed request for a team November 25, 2024 14:53
@undsoft undsoft self-requested a review November 27, 2024 09:15
Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

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

The code looks good, but I just couldn't get it to work on a CI machine.
I can see token being sent to middleware, but it just returns AUTH_ERR for some reason.

@aervin aervin requested review from RehanY147 and undsoft December 2, 2024 17:52
@aervin
Copy link
Collaborator Author

aervin commented Dec 2, 2024

Went to retest against a CI machine and the hasOpened logic was already flaky/broken. As an alternative approach, I've manually preserved query params on redirect in the resetUi method.

Seems to work fine against a CI machine with both root and non-builtin users.

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

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

I still get the same issue:

2024-12-03.11.13.03.mov

@RehanY147 RehanY147 removed their request for review December 3, 2024 22:04
@aervin aervin merged commit 357cc9f into master Dec 5, 2024
9 checks passed
@aervin aervin deleted the NAS-132648 branch December 5, 2024 20:30
@bugclerk
Copy link
Contributor

bugclerk commented Dec 5, 2024

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants