wip/authorization-header #7
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: gorb/backend#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wip/authorization-header"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Uses authorization headers instead of keeping access_token and refresh_token in body.
Needs testing, just ask if something is unclear here
auth header is used for
access_token
Changes
Moved everything to /api
POST -> GET /v1/users/me
Request: auth header
POST -> GET /v1/users/{uuid}
Request: auth header
POST -> GET /v1/users
Request: auth header and query params
start=int
andamount=int
POST /v1/auth/register
Response: Remove
refresh_token
from body and instead set-cookierefresh_token
POST /v1/auth/login
Response: Remove
refresh_token
from body and instead set-cookierefresh_token
POST /v1/auth/refresh
Request: cookie
refresh_token
Response: Remove
refresh_token
from body and instead set-cookierefresh_token
POST /v1/auth/revoke
Request: auth header (password still in body)
wip/authorization-headerto WIP: wip/authorization-headerPlease add
Set-Cookie: refresh_token={token}; HttpOnly; Secure; SameSite=None; Path=/api/; Max-Age=0
to the 401 response of the /refresh endpoint and the 200 response of the /revoke endpoint so the browser deletes the cookie.@sauceyred wrote in #7 (comment):
adding it to the 200 of the revoke response doesnt make sense unless you're revoking your own cookie?
@radical wrote in #7 (comment):
When you log out (call the /revoke endpoint), the access and refresh tokens are invalidated, so the refresh token cookie should be deleted to reflect that, no?
@sauceyred wrote in #7 (comment):
revoke isnt a logout endpoint, its to logout other clients logged into your account, we dont have any way to log yourself out yet lmao
also why does the backend need to set it to 0, shouldnt the frontend just remove the token if it gets a 401?
@radical wrote in #7 (comment):
Fair enough, I've just been using the revoke as a logout endpoint for testing and found it to be working fine, but yeah it doesn't make as much sense for logging out of your local session.
@radical wrote in #7 (comment):
Because the client can't touch the refresh token cookie since it has the HttpOnly flag, meaning it can't be accessed through JavaScript, a response with a Set-Cookie header is required.
@sauceyred wrote in #7 (comment):
Isnt there a way to remove the cookie? It seems very crude to set it in this way instead of removing it outright when its invalid
@radical wrote in #7 (comment):
This is the way to remove the cookie. That's why 401 on refresh 200 on logout should send back a Set-Cookie header to remove it.
apparently actix has a built in for this, ill implement it
https://docs.rs/actix-web/latest/actix_web/cookie/struct.Cookie.html#method.make_removal
@radical wrote in #7 (comment):
Hell yeah
revoke will not be changed however, we'll have a separate endpoint for logout
@radical wrote in #7 (comment):
Agreed
Changes work as intended.
WIP: wip/authorization-headerto wip/authorization-header