Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed /auth endpoint returns a 202 status code regardless of whether the token has expired #2302

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mohsek
Copy link

@mohsek mohsek commented Oct 30, 2023

Description

the endpoint /oauth2/auth doesn't check the expiration date of the token in the session. so when calling the endpoint it return always a response 202 if the session exists, but it never checks if the session has expired.

Motivation and Context

fixes #1836 (complementary to #1955)

How Has This Been Tested?

tested with real environment with oidc (wso2) and nginx

  • wso2 config: token expiration time : 5min, refresh token expiration time: 24h
  • oauth2-config: cookie-expire: 30mn; cookie-refresh: 10mn
  • send request, after token expiration time and before refresh cookie.
  • the /oauth2/auth request should return 401 and not 202

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.

@mohsek mohsek requested a review from a team as a code owner October 30, 2023 17:40
@tuunit
Copy link
Member

tuunit commented Oct 30, 2023

Hi @mohsek,

thank you for the contribution but we do have a contribution guide and a PR description template that is automatically applied when you open a PR via the GitHub UI. Please update your description according to:

https://github.com/oauth2-proxy/oauth2-proxy/blob/master/.github/PULL_REQUEST_TEMPLATE.md

Especially a changelog entry and testing is missing.

@tuunit
Copy link
Member

tuunit commented Oct 30, 2023

Furthermore, we need to check if this would interfere with the token refresh flow. Especially this PR: #1955

Copy link
Member

@tuunit tuunit left a comment

Choose a reason for hiding this comment

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

Please add back the empty lines. They are kept for readibility. Please add a test cases for the changed behaviour.

@mohsek mohsek changed the title Authorize return false if session has expired fix authorize return true if session has expired Oct 31, 2023
@mohsek mohsek changed the title fix authorize return true if session has expired Fixed /auth endpoint returns a 202 status code regardless of whether the token has expired Oct 31, 2023
@github-actions github-actions bot added the tests label Nov 6, 2023
@tuunit tuunit added the LGTM PR is ready to merge label Nov 18, 2023
@JoelSpeed
Copy link
Member

This has been a topic that has come up a few times throughout the OAuth2 Proxy project, and, I think changing it would be a breaking change.

We know in the past we have had users that have not cared about tokens and their expiry, they just want to limit logins to a particular group, eg using the hosted domain functionality on Google, but don't care how long that session exists for.

Changing the default here has the possibility to severely degrade the user experience of use cases such as this.

If we want to have this change, it needs to be gated and switched to default in a major release

@JoelSpeed JoelSpeed removed the LGTM PR is ready to merge label Nov 18, 2023
@tuunit tuunit added this to the v8.0.0 milestone Nov 19, 2023
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 19, 2024
@rbange
Copy link

rbange commented Jan 19, 2024

This is still a desired feature.

@github-actions github-actions bot removed the Stale label Jan 20, 2024
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 Mar 22, 2024
@mohsek
Copy link
Author

mohsek commented Mar 22, 2024

Still a relevant feature

@github-actions github-actions bot removed the Stale label Mar 25, 2024
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 May 24, 2024
@mohsek
Copy link
Author

mohsek commented May 24, 2024

still desired feature.

@github-actions github-actions bot removed the Stale label May 25, 2024
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 Jul 24, 2024
@mohsek
Copy link
Author

mohsek commented Jul 24, 2024

Still a relevant feature

@github-actions github-actions bot removed the Stale label Jul 25, 2024
Copy link
Member

@tuunit tuunit left a comment

Choose a reason for hiding this comment

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

Please resolve the merge conflict. The rest LGTM

@@ -17,7 +17,8 @@
- [#2282](https://github.com/oauth2-proxy/oauth2-proxy/pull/2282) Fixed checking Google Groups membership using Google Application Credentials (@kvanzuijlen)
- [#2183](https://github.com/oauth2-proxy/oauth2-proxy/pull/2183) Allowing relative redirect url though an option
- [#1866](https://github.com/oauth2-proxy/oauth2-proxy/pull/1866) Add support for unix socker as upstream (@babs)

- [#2302](https://github.com/oauth2-proxy/oauth2-proxy/pull/2302) Fixed /auth endpoint returns code 202 regardless of whether the token has expired (@mohsek)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- [#2302](https://github.com/oauth2-proxy/oauth2-proxy/pull/2302) Fixed /auth endpoint returns code 202 regardless of whether the token has expired (@mohsek)
- [#2302](https://github.com/oauth2-proxy/oauth2-proxy/pull/2302) Bugfix: /auth endpoint now returns invalid authentication for expired tokens (@mohsek)

@tuunit
Copy link
Member

tuunit commented Aug 5, 2024

I agree with Joel this might be a breaking change for some users. There is another PR that wants to introduce a new option to actively skip validation of expiry. Which might be a good match for the changes proposed here.

Copy link
Contributor

github-actions bot commented Oct 6, 2024

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 6, 2024
@tuunit tuunit removed the Stale label Oct 6, 2024
@JoelSpeed
Copy link
Member

@tuunit What is the alternative PR you mention?

@gempir
Copy link

gempir commented Nov 26, 2024

This is a pretty unintuitive behaviour for new users of oauth2-proxy though IMO. When I have my application behind the proxy I expect the access token to be valid, otherwise why would I be using oauth2-proxy.

Gating it behind a flag makes sense for backwards-compatiblity, but what exactly is going to break here, the refresh happens more frequently? Is that a breaking change?

I would prefer the "secure" option to be the default, so refreshing the access token, since Keycloak or whatever OIDC Provider provided the access token said "hey this token is valid for X Time, please refresh it when that time is over.

@JoelSpeed
Copy link
Member

the refresh happens more frequently? Is that a breaking change?

Not everyone has the refresh configured and/or working correctly, so for certain users, it would limit the length of their sessions to whatever their IDP configures, rather than giving them that control at the OAuth2 Proxy layer

I would prefer the "secure" option to be the default

Yes, but lets introduce a way to retain the old behaviour, and flick the breaking change at a major version boundary

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

Successfully merging this pull request may close these issues.

oauth2-proxy sends expired access tokens to backend
5 participants