Skip to content

Session aware logout, backend logout url approach - #1876

Merged
JoelSpeed merged 13 commits into
oauth2-proxy:masterfrom
babs:backend-logout
Jan 26, 2024
Merged

JoelSpeed merged 13 commits into
oauth2-proxy:masterfrom
babs:backend-logout

Conversation

@babs

@babs babs commented Oct 31, 2022 •

Copy link
Copy Markdown
Contributor

Description

This PR implements backend logout approach, might be better than #1875 and might also satisfy #884

Motivation and Context

Implement backend logout.

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.
  • I have created a feature (non-master) branch for my PR.

@babs
babs requested a review from a team as a code owner October 31, 2022 21:40
babs added a commit to babs/oauth2-proxy that referenced this pull request Oct 31, 2022
@babs

babs commented Oct 31, 2022

Copy link
Copy Markdown
Contributor Author

I can't do much for legacyProviderFlagSet LoC count :/

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 28, 2023
@babs

babs commented Jan 28, 2023

Copy link
Copy Markdown
Contributor Author

Still relevant;)

@JoelSpeed JoelSpeed removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 30, 2023
@JoelSpeed

Copy link
Copy Markdown
Member

Apologies for not getting to this, I hope to review soon, looks like there are a couple of conflicts in the keycloak code at the moment, do we want to get those resolved?

@babs

babs commented Feb 20, 2023

Copy link
Copy Markdown
Contributor Author

Conflicts resolved, ready to merge.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 22, 2023
@babs

babs commented Apr 22, 2023

Copy link
Copy Markdown
Contributor Author

Not stale

@gchait

gchait commented Apr 23, 2023

Copy link
Copy Markdown

Thank you for that, would love to see it merged soon!

@github-actions github-actions Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 24, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 23, 2023
@babs

babs commented Jun 23, 2023

Copy link
Copy Markdown
Contributor Author

Still relevent

@github-actions github-actions Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 24, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 24, 2023
@babs

babs commented Aug 24, 2023

Copy link
Copy Markdown
Contributor Author

.

@github-actions github-actions Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 25, 2023
babs added a commit to babs/oauth2-proxy that referenced this pull request Oct 7, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 24, 2023
@babs

babs commented Oct 24, 2023

Copy link
Copy Markdown
Contributor Author

.

@github-actions github-actions Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 25, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 24, 2023
babs and others added 6 commits January 22, 2024 12:51
As this should be specified in a URL and curly braces should be escaped as %7b and %7d, therefore using {} shouldn't be an issue
Co-authored-by: Joel Speed <[email protected]>
@babs

babs commented Jan 22, 2024

Copy link
Copy Markdown
Contributor Author

Rebased against master

@babs

babs commented Jan 25, 2024

Copy link
Copy Markdown
Contributor Author

Rebased against master

@JoelSpeed
JoelSpeed merged commit e7d2051 into oauth2-proxy:master Jan 26, 2024
@andrewkcarter

Copy link
Copy Markdown

Excellent. When is the next release scheduled?

kaktus42 pushed a commit to FES-Ehemalige/redmine_proxyauth that referenced this pull request Jul 27, 2024
backend logout can now be performed with oauth-proxy:
oauth2-proxy/oauth2-proxy#1876
@babs

babs commented Aug 19, 2024

Copy link
Copy Markdown
Contributor Author

Several logout methods has been considered but as id_token is a pretty sensitive information, backend logout has beeen privilegied.

You have to consider 2 course of actions when you send the browser to the sign_out endpoint, running in parallel:

  • Client side you want the browser to be redirected on a gien url (the rd parameter in qs)
  • Server to server call from oauth2-proxy to your oidc provider (keycloak) through a secure channel with pattern replacement containing the sensitive info

So http://localhost:8080/auth/realms/testrealm/protocol/openid-connect/logout?id_token_hint={id_token} goes into --backend-logout-url and http://localhost:4180/ goes to rd argument of sign_out.

@ch08532

ch08532 commented Sep 6, 2024

Copy link
Copy Markdown

Hello, please write some documentation, the description is scant, what should I do about it? do I understand correctly that the application should follow http://app.app.example/logout where nginx location follows in this link http://localhost:4180/oauth2/sign_out?rd=http://localhost:8080/auth/realms/testrealm/protocol/openid-connect/logout?id_token_hint={id_token}%26post_logout_redirect_uri=http:// localhost:4180/ what then should be in the backend-logout-url

I was able to get this to work with NGINX proxy and Keycloak OIDC provider:

OAuth2proxy config file entry:

backend_logout_url="http://keycloak.local/realms/redeye/protocol/openid-connect/logout?post_logout_redirect_uri=https%3A%2F%2Fapp.local&id_token_hint={id_token}"

NGINX entry:

# Logout route
location /logout {
        proxy_pass http://oauth2-proxy:4180/oauth2/sign_out; 

        include       /etc/nginx/proxy_params;
        proxy_set_header Cookie                  $http_cookie;  # Forward session cookies
    }

@babs

babs commented Sep 6, 2024 •

Copy link
Copy Markdown
Contributor Author

Good news.
But again you don't need to specify post_logout_redirect_uri keycloak parameter in oauth2-proxy's backend_logout_url option.

@ch08532

ch08532 commented Sep 6, 2024 •

Copy link
Copy Markdown

Good news. But again you don't need to specify post_logout_redirect_uri keycloak parameter in oauth2-proxy's backend_logout_url option.

Thanks for the response! I tested it, and it works just as you described. Here's an updated config snippet for reference to help others:

backend_logout_url="http://keycloak.local/realms/redeye/protocol/openid-connect/logout?id_token_hint={id_token}"

@babs

babs commented Sep 6, 2024

Copy link
Copy Markdown
Contributor Author

Glad to hear that ;)

@redboxstudio

Copy link
Copy Markdown

Good news. But again you don't need to specify post_logout_redirect_uri keycloak parameter in oauth2-proxy's backend_logout_url option.

Why? How to back in app?
mb this need add to nginx conf ?
location /logout {
proxy_pass http://oauth2-proxy:4180/oauth2/sign_out?rd=https://myapp.local;

@babs

babs commented Sep 13, 2024

Copy link
Copy Markdown
Contributor Author

More like that, yes ;)

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

Labels

docs go lgtm "Looks good to me", indicates that a PR is ready to be merged. provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants