Skip to content

Conversation

@babs
Copy link
Contributor

@babs babs commented Oct 31, 2022

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
Copy link
Contributor Author

babs commented Oct 31, 2022

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

@github-actions
Copy link
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 Stale label Jan 28, 2023
@babs
Copy link
Contributor Author

babs commented Jan 28, 2023

Still relevant;)

@JoelSpeed JoelSpeed removed the Stale label Jan 30, 2023
@JoelSpeed
Copy link
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
Copy link
Contributor Author

babs commented Feb 20, 2023

Conflicts resolved, ready to merge.

@github-actions
Copy link
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 Stale label Apr 22, 2023
@babs
Copy link
Contributor Author

babs commented Apr 22, 2023

Not stale

@gchait
Copy link

gchait commented Apr 23, 2023

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

@github-actions github-actions bot removed the Stale label Apr 24, 2023
@github-actions
Copy link
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 Stale label Jun 23, 2023
@babs
Copy link
Contributor Author

babs commented Jun 23, 2023

Still relevent

@github-actions github-actions bot removed the Stale label Jun 24, 2023
@github-actions
Copy link
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 Stale label Aug 24, 2023
@babs
Copy link
Contributor Author

babs commented Aug 24, 2023

.

@github-actions github-actions bot removed the 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
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 Stale label Oct 24, 2023
@babs
Copy link
Contributor Author

babs commented Oct 24, 2023

.

@github-actions github-actions bot removed the Stale label Oct 25, 2023
@github-actions
Copy link
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 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: Jan Larwig <jan@larwig.com>
Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
@babs
Copy link
Contributor Author

babs commented Jan 22, 2024

Rebased against master

@babs
Copy link
Contributor Author

babs commented Jan 25, 2024

Rebased against master

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

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
@redboxstudio
Copy link

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

@babs
Copy link
Contributor Author

babs commented Aug 19, 2024

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
Copy link

ch08532 commented Sep 6, 2024

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
Copy link
Contributor Author

babs commented Sep 6, 2024

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
Copy link

ch08532 commented Sep 6, 2024

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
Copy link
Contributor Author

babs commented Sep 6, 2024

Glad to hear that ;)

@redboxstudio
Copy link

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
Copy link
Contributor Author

babs commented Sep 13, 2024

More like that, yes ;)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants