Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable logout redirection for reverse proxy setups#36085

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
eliroca wants to merge1 commit intogo-gitea:main
base:main
Choose a base branch
Loading
fromeliroca:logout_redirect_main

Conversation

@eliroca
Copy link

When authentication is handled externally by a reverse proxy or SSO provider, users can be redirected to an external logout URL or relative path defined on the reverse proxy.

@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelDec 4, 2025
@github-actionsgithub-actionsbot added modifies/goPull requests that update Go code modifies/templatesThis PR modifies the template files docs-update-neededThe document needs to be updated synchronously labelsDec 4, 2025
m.Post("/recover_account",auth.ResetPasswdPost)
m.Get("/forgot_password",auth.ForgotPasswd)
m.Post("/forgot_password",auth.ForgotPasswdPost)
m.Get("/logout",auth.SignOut)
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of this route? Convenience for testing?

Copy link
Author

Choose a reason for hiding this comment

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

The button gets also changed to do a GET request by settinghref. As I understand it, a GET request is needed to also cleanly redirect the user to the external URL.

Copy link
Author

Choose a reason for hiding this comment

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

We could think about simplifying the "Sign out" button to just do a GET /user/logout always, to not have to check whether we have this new config setting.

Copy link
Member

@silverwindsilverwindDec 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

Hmm I think we ought to keep the POST for compatibilty reasons. Some users may have special integrations with the POST route in their reverse proxy.

Copy link
Member

@silverwindsilverwindDec 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

As I understand it, a GET request is needed to also cleanly redirect the user to the external URL.

If I understand HTTP correctly, one can also redirect in a POST response, can you try that? Logging out is a action that likely changes state on the server so a GET is semantically incorrect.

Copy link
Member

Choose a reason for hiding this comment

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

Thought that does present a challenge in the styling because we don't have CSS to style a button like a link. Could you show a screenshot of how this link currently looks?

Copy link
Author

Choose a reason for hiding this comment

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

Screencast.From.2025-12-04.22-27-40.mp4

Copy link
Member

Choose a reason for hiding this comment

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

after checking the code, maybe I know why you think post atcion can't be used for redirect action, first, we should comfirm curent logout steps: first do POST/logout by js, backed will response a json struct wich containredirect=xxxx, then js will call a speciall post action to/-/fetch-redirect with a form contain redirect link, then the backen will do a redirect.
ref:
image
image

but sadly, in current design,/-/fetch-redirect will will block link to ather service, maybe we can remove this block, or render a warning page with a link for it. /cc@wxiaoguang
image

Copy link
Contributor

@wxiaoguangwxiaoguangDec 5, 2025
edited
Loading

Choose a reason for hiding this comment

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

but sadly, in current design,/-/fetch-redirect will will block link to ather service, maybe we can remove this block, or render a warning page with a link for it. /cc@wxiaoguang

No, the design is right. Otherwise "open redirect" security vulnerabilities.

You can allow more URL patterns which are known to be safe, but not remove it or bypass it.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the PR so that the "Sign Out" link does an actual POST, please review.

silverwind reacted with thumbs up emoji
@elirocaelirocaforce-pushed thelogout_redirect_main branch 3 times, most recently fromd093cd4 to8d868acCompareDecember 9, 2025 08:48
@eliroca
Copy link
Author

Updated the test, POST on/user/logout now returns a 303 redirect to/

When authentication is handled externally by a reverse proxy or SSO provider,users can be redirected to an external logout URL or relative pathdefined on the reverse proxy.
<divclass="divider"></div>
<aclass="item link-action" hrefdata-url="{{AppSubUrl}}/user/logout">
<formid="logout-form"method="post"action="{{AppSubUrl}}/user/logout"></form>
<aclass="item"onclick="document.getElementById('logout-form').submit();">
Copy link
Member

Choose a reason for hiding this comment

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

It’s not recommended to use an event handler in this style.

Copy link
Author

Choose a reason for hiding this comment

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

I'm open to suggestions.@silverwind, you wrote:

inline<form> to trigger the POST and change the link to a button with type=submit, so it works without JS.
Thought that does present a challenge in the styling because we don't have CSS to style a button like a link.

Could you help with styling a button?

Copy link
Member

@silverwindsilverwindDec 11, 2025
edited
Loading

Choose a reason for hiding this comment

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

Yeah I guess I can take a look a bit later. We need to move the event handler to TS (inline scripts are a no-go for strict CSP) and do the styling.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lunnylunnylunny left review comments

@silverwindsilverwindsilverwind left review comments

@wxiaoguangwxiaoguangwxiaoguang left review comments

+1 more reviewer

@a1012112796a1012112796a1012112796 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

docs-update-neededThe document needs to be updated synchronouslylgtm/need 2This PR needs two approvals by maintainers to be considered for merging.modifies/goPull requests that update Go codemodifies/templatesThis PR modifies the template files

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@eliroca@lunny@silverwind@wxiaoguang@a1012112796@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp