-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
oauth improvements #9217
oauth improvements #9217
Conversation
Dear team I am proposing you this patch to improve the OIDC use, I am currently using it for my personal use on the 1.6.5 version I would like to thanks also @Westie for his work (I included it in this PR) Let me know if you prefer non squashed PR Kind regards |
Thank you very much for this patch! This would also fix #8201. |
I have tested this PR. Discovery works well, a thousand thanks for this! As the specification recommend to pass the It was discussed a few years ago in #8214, at the time the maintainers preferred not to keep the id_token in the session. @thomascube and @alecpl would you reconsider this? I don't know if that was for security reasons, but nowadays with RFC9068 and people using JWT access tokens containing more or less the same payload than the |
As we have the discovery, I took opportunity to fetch jwks (certificates) to verify JWT signatures, it is important for backchannel call to trust foreign calls A future PR will come, for manual setup it will be config option |
If the If What do you think? |
@azmeuk I will check your remarks, currently the |
One last thing. I noticed Looking closer at the OIDC spec, it seems the refresh token request should not return an id_token anyways:
Thus, to be able to fill |
35fdfb7
to
d79f367
Compare
here is some improvements:
@azmeuk if you test you can activate the debug option |
Hi @EdouardVanbelle, I will try to test this soon. |
Hello @azmeuk , I pushed the version with the backchannel logout, you can add in your IDP a callback to regarding the pull request, I need to check with @alecpl due to sensitivity of this patch it could be time to add tests before and after this patch, for that I need to learn how to code in php :) Right now I considered that it is overkill to redevelop a full JWT parser, so I used |
24b4adf
to
723c89c
Compare
Hello @alecpl let me know if you need to split the pull request or rebase/squash it to make it more easier to review |
3bbe9b1
to
0da86ca
Compare
1f244aa
to
720cb91
Compare
* Add `oauth_config_uri` to parse the .well-known/openid-configuration and discover `oauth_*_uri` * Add `oauth_logout_uri` and support of OIDC RP-initiated Logout with ìd_token_hint & client_id (credit: @Westie) * Add `oauth_issuer` to check JWT * Add `jwks_uri` used to fetch JWKS certificates * Add support of OIDC Back-Channel Logout (url: <roundcube>/index.php/login/backchannel) (security improvement) * Add support of OAUTHBEARER * Fix: missing config `oauth_provider_name` in constructor * Improvement: move display to the rcmail_oauth class and use `loginform_content` hook * Add `oauth_debug` to trace OIDC/Oauth events (target: <default log path>/oauth.log ) * Improvement: align access_token expiration with refresh frequency * Improvement: store refresh_token expiration * Fix leak of access_token * Improvement: add unit tests
720cb91
to
d81eba0
Compare
To follow |
Hello @alecpl you have the next coming changes on another branch (once this one is approved)
|
@EdouardVanbelle So, the last part here that is not clear is that one with 'min_refresh_interval'. Since you already know this code better than me, could you take a look at #9244 for feedback, please. |
Signed-off-by: Edouard Vanbelle <[email protected]>
Please, fix the code style issues. We deployed code style checking in CI. |
@alecpl here it is ! |
@EdouardVanbelle Thank you for this work and I'm waiting for more! |
@EdouardVanbelle: Good job! |
@EdouardVanbelle Could you share a bit how to configure logout for keycloak? I've updated Roundcube, and attempted to use the new configs, but I can't seem to log off. I noticed now that, with Keycloak, |
Hello @oculos , here is my configuration: tip concerning your Roundcube config:(on my side I have enabled the debugging) $config['oauth_debug'] = true;
$config['oauth_provider'] = 'generic';
$config['oauth_provider_name'] = 'Vanbelle';
$config['oauth_client_id'] = 'YOUR-CLIENT-ID';
$config['oauth_client_secret'] = '#######';
$config['oauth_config_uri'] = 'https://YOUR-KEYCLOAK-DOMAIN/realms/YOUR-REALM/.well-known/openid-configuration';
$config['oauth_verify_peer'] = true;
$config['oauth_scope'] = "email openid";
$config['oauth_auth_parameters'] = [];
$config['oauth_identity_fields'] = ['email'];
// setup to true once config ok to remove user/pass prompt and redirect to oauth login
$config['oauth_login_redirect'] = false;
$config['oauth_cache'] = 'db';
$config['oauth_cache_ttl'] = '1d'; Keycloak config:
Debugging backchannelTo try backchannel logout: If you are on your Keycloak account in user: on your roundcube's log directory, if you enabled debug on config (set
Debugging postlogoutonce logged in Roundcube, just logout, it should propagate to Keycloak the logout request:
and your session on keycloak should be kicked |
Thanks a lot @EdouardVanbelle Not even the debug is working:
I created the oauth.log file because it wasn't created at all. and it's still empty despite debug is on. So something is not working as it should. I see that when I click logout, the url displays this: https://mail.med-lo.eu/webmail/?_task=logout&_token=BZgxxxxxxxx But clicking on login again sends me right back. |
$config['oauth_cache'] = 'db';
$config['oauth_cache_ttl'] = '1d'; could you confirm you enabled it ? if config uri does not work, you should have the reason in your |
This is my configuration:
If I comment out Absolutely no new errors on |
@oculos even if you comment out Could you let met know which commit you are working on ? so I could check to reproduce
(feature is right now only available on master's branch which is still in development ) |
Ohhh now I see. I mistakenly thought this was already added to the package that is publicly available (1.6.7). You see, I don’t install from the repo, I just download the package from Roundcube’s website. |
No worries @oculos, at least I provided a sample of use ;) |
oauth_config_uri
to parse the .well-known/openid-configuration and discoveroauth_*_uri
oauth_logout_uri
support of Support for OpenID Connect RP-Initiated Logout #9109 (security improvement) (credit: @Westie)oauth_provider_name
in rcmail_oauth's constructorloginform_content
hook