Repository navigation
feat: provision users from the userinfo endpoint (opaque bearer tokens) - #1564
alex-yatsenko wants to merge 1 commit into
Conversation
UserInfoValidator returned an empty string from getProvisioningStrategy() with a TODO, so users authenticated with an **opaque** bearer token were never provisioned: the token carries no claims, and nothing fetched them from the provider's userinfo endpoint either. Providers that issue opaque access tokens (instead of self-encoded JWTs) therefore got no group membership and no attribute sync on the bearer path. Add UserInfoProvisioning, the counterpart of SelfEncodedTokenProvisioning: it takes the payload from the provider's userinfo endpoint instead of decoding it out of the token. UserInfoValidator now names that strategy, so the existing "bearer provisioning" setting works for opaque tokens too. The class deliberately mirrors SelfEncodedTokenProvisioning and reuses ProvisioningService, so the group whitelist filter keeps applying exactly as before. Refs nextcloud#1258 Refs nextcloud#1255 Signed-off-by: Александр Яценко <286242565+alex-yatsenko@users.noreply.github.com>
f8259a5 to
6be4327
Compare
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Implements the TODO in
UserInfoValidator::getProvisioningStrategy()— the one tracked in #1258, and related to #1255.Why
UserInfoValidatorvalidates opaque access tokens by calling the provider'suserinfoendpoint, but it returned an empty string fromgetProvisioningStrategy(), andBackendskips provisioning entirely when the strategy is empty:A self-encoded JWT carries its claims, so
SelfEncodedTokenProvisioningcan decode them. An opaque token carries nothing — the claims only exist behinduserinfo. For providers that issue opaque tokens the account still gets created, but group membership and attribute sync never happen, and nothing is logged: the failure is completely silent.What
OCA\UserOIDC\User\Provisioning\UserInfoProvisioning— counterpart ofSelfEncodedTokenProvisioning, deliberately mirroring it and differing only in where the payload comes from (OIDCService::userinfo()instead ofJWT::decode()). It reusesProvisioningService::provisionUser(), so the group whitelist (groupWhitelistRegex) and all mapping settings keep applying exactly as before — it does not add a way around them.UserInfoValidator::getProvisioningStrategy()now returnsUserInfoProvisioning::class. If fetchinguserinfofails at provisioning time it logs the error and returnsnull: the very same token was just validated against that endpoint in the validator, so a failure here is a transport failure, not an authorization one.ProvisioningService, endpoint failure is handled and does not provision).Testing
php -lon all changed files.tests/unit/User/Provisioning/UserInfoProvisioningTest.php.We are happy to reshape this to whatever the maintainers prefer (e.g. sharing code with
SelfEncodedTokenProvisioning, or wiring the strategy differently) — the point is that the bearer path should provision like the interactive one does.Refs #1258
Refs #1255