mirror of
https://github.com/go-shiori/shiori.git
synced 2026-04-25 14:35:52 +03:00
[PR #1069] [MERGED] fix: auth validation on existing sessions, rely on token only #968
Labels
No labels
component:backend
component:builds
component:builds
component:extension
component:frontend
component:readability
database
database:mysql
database:postgres
database:sqlite
feature:ebooks
github_actions
good first issue
hacktoberfest
note:duplicate?
note:fixed?
note:out-of-scope?
os:windows
priority:high
priority:low
pull-request
resolution:as-intended
resolution:cant-reproduce
resolution:duplicate
resolution:fixed
resolution:wontfix
tag:TBD
tag:big-task
tag:help-wanted
tag:huge-data
tag:meta
tag:more-info
tag:next
tag:no-stale
tag:requires-migrations
tag:research
tag:security 🛡️
tag:stale
tag:waiting-for-assignee
type:bug
type:documentation
type:enhancement
type:meta
type:ux
user:cli
user:web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shiori#968
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/go-shiori/shiori/pull/1069
Author: @fmartingr
Created: 2/27/2025
Status: ✅ Merged
Merged: 2/28/2025
Merged by: @fmartingr
Base:
master← Head:fix/auth-cookie-validation📝 Commits (9)
ef4e0ddchore: use http.NoBodye217406fix: remove cookie token on logout198b069fix: remove token cookie on middleware and redirectf70972afix: frontend sets cookie token if authenticatedab3ecbarefactor: remove session-id, rely on token only0fe50e1docs: make swaggera5489bafix: redirect551ce87fix: archive route handler528b303fix: properly unset cookie📊 Changes
17 files changed (+124 additions, -169 deletions)
View changed files
📝
docs/swagger/docs.go(+0 -5)📝
docs/swagger/swagger.json(+0 -5)📝
docs/swagger/swagger.yaml(+0 -4)📝
internal/http/handlers/api/v1/accounts_test.go(+2 -6)📝
internal/http/handlers/api/v1/auth.go(+9 -11)📝
internal/http/handlers/api/v1/auth_test.go(+5 -21)📝
internal/http/handlers/bookmark.go(+1 -3)📝
internal/http/handlers/legacy.go(+6 -3)📝
internal/http/handlers/legacy_test.go(+1 -25)📝
internal/http/middleware/auth.go(+8 -2)📝
internal/http/middleware/auth_test.go(+33 -0)📝
internal/http/server.go(+2 -5)📝
internal/view/assets/js/component/login.js(+1 -7)📝
internal/view/assets/js/page/base.js(+1 -1)📝
internal/view/index.html(+9 -3)📝
internal/webserver/handler.go(+42 -64)📝
internal/webserver/server.go(+4 -4)📄 Description
This pull request includes several changes aimed at removing the legacy session handling and improving the authentication process by using token-based authentication. The most important changes include the removal of the legacy session handling, updating the login and logout handlers, and ensuring the token is properly managed in the client-side code.
Removal of Legacy Session Handling:
internal/http/handlers/api/v1/auth.go: Removed the legacy session ID handling and related code from theHandleLoginfunction. [1] [2]internal/http/handlers/legacy.go: Removed legacy session cache handling in theHandleLoginandHandleLogoutfunctions.internal/webserver/handler.go: Removed the session cache and related methods, replacing them with token validation. [1] [2]Update Login and Logout Handlers:
internal/http/handlers/api/v1/auth.go: Updated theHandleLogoutfunction to remove the token cookie instead of the session ID.internal/http/middleware/auth.go: Modified theOnRequestmethod to remove the token cookie and redirect to login if token validation fails.Client-Side Token Management:
internal/view/assets/js/component/login.js: Updated the login process to set and clear the token cookie instead of the session ID. [1] [2] [3]internal/view/index.html: Ensured the token cookie is set and cleared properly during login and logout processes. [1] [2] [3]Test Updates:
internal/http/handlers/api/v1/accounts_test.go: Updated tests to remove the use of the legacy login handler. [1] [2]internal/http/handlers/api/v1/auth_test.go: Removed the legacy login handler and updated tests accordingly. [1] [2] [3]internal/http/handlers/legacy_test.go: Removed tests related to the legacy session cache. [1] [2]🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.