Repository navigation
Description
Behaviour
The android app tries to do a OIDC client registration with a custom OIDC provider.
This works successful but the registered client has some "optimistic" assumptions.
Expected behaviour
The client does a full defined request, with all arguments.
Steps to reproduce
A bit hard to describe I used:
- OCIS v 2.0.0beta5
- Ory/Hydra as Oauth2 Provider
- Custom identity provider
If you need a more precise description ask, it is my testsystem, can also give access if requested.
Can this problem be reproduced with the official owncloud server?
(url: https://demo.owncloud.org, user: test, password: test)
NO
Environment data
Android version:
Lineageos 18.1
Device model:
Stock or customized system:
ownCloud app version:
github - master
ownCloud server version:
OCIS 2.0.0beta5
Logs
Web server error log
Insert your webserver log here
ownCloud log (data/owncloud.log)
Insert your ownCloud log here
Sample Patch (but quick and dirty):
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/oauth/params/ClientRegistrationParams.kt
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/oauth/params/ClientRegistrationParams.kt
@@ -46,6 +46,8 @@ data class ClientRegistrationParams(
put(PARAM_CLIENT_NAME, clientName)
put(PARAM_REDIRECT_URIS, JSONArray(redirectUris))
put(PARAM_TOKEN_ENDPOINT_AUTH_METHOD, tokenEndpointAuthMethod)
+ put(PARAM_SCOPE, "openid offline_access email profile")
+ put("grant_types", JSONArray(arrayOf("authorization_code","refresh_token")))
}.toString().toRequestBody(CONTENT_TYPE_JSON.toMediaType())
companion object {
@@ -53,5 +55,6 @@ data class ClientRegistrationParams(
private const val PARAM_CLIENT_NAME = "client_name"
private const val PARAM_TOKEN_ENDPOINT_AUTH_METHOD = "token_endpoint_auth_method"
private const val PARAM_REDIRECT_URIS = "redirect_uris"
+ private const val PARAM_SCOPE = "scope"
}
}
This patch addes the arguments:
scope- defines witch sopes should be allowed to request, default not defined in rfcgrant_type- default is only["authorization_code"]but ist should be IMHO["authorization_code","refresh_token"]
The current implementation assumes that the default parameter are correct but that is implementation specific.
I could apply the patch above to a testbuild on my phone and it looks like it works.
The client does registration a new OIDC client with the right paramters.
as api reference I used: https://www.ory.sh/docs/hydra/reference/api
and the rfc: https://datatracker.ietf.org/doc/html/rfc7591#section-2
I'm not so into Kotline, so I would let to a dev to do the nice implementation
Activity
michaelstingl commentedon Jul 29, 2022
@d7oc maybe this is useful for you?
/cc involving the OIDC experts and the other clients… @DeepDiver1975 @wkloucek @TheOneRing @IljaN @felix-schwarz
DeepDiver1975 commentedon Jul 29, 2022
Generally speaking I'd prefer to keep the params to a minimum. As per spec both params can be omitted.
I fear that this will break interop with other IdPs ....
TuxCoder commentedon Jul 29, 2022
Hi @DeepDiver1975 I agree to keep it at a min.
for that reason I would not define
response_typesnortoken_endpoint_auth_methodas the defaults are fine.but in the rfc7591 is written:
grant_types:but the app requires
["authorization_code","refresh_token"]same for
scope, there is no default amount of scopesbut the app requires:
"openid offline_access email profile", what is the default set?breaking inter op:
all standard conform implementation should be capable to handle this parameters,
if not they are already broken and should be fixed
felix-schwarz commentedon Jul 29, 2022
The iOS client gets away with not sending any
grant_types, which - per the documentation you also quoted - really only means["authorization_code"].It can apparently omit the
refresh_tokengrant type because including theoffline_accessscope already ensures it gets a refresh token:This scope value requests that an OAuth 2.0 Refresh Token be issued that can be used to obtain an Access Token that grants access to the End-User's UserInfo Endpoint even when the End-User is not present (not logged in).(OpenID Connect Core 1.0 Spec)
The iOS client requests the
openid offline_access email profilescopes.TuxCoder commentedon Jul 29, 2022
@felix-schwarz
that is true, but how to use a refresh_token if you can not do a
grant_type=refresh_tokenat a token endpoint,This is probably a bit strange done in the standard, but IMHO you need
grant_type=refresh_tokento use the refresh_token,so its kind of required but not directly written.
see: https://www.rfc-editor.org/rfc/rfc6749#section-6
grant_type=refresh_tokenis also used in the code: https://github.com/owncloud/android/blob/master/owncloudDomain/src/main/java/com/owncloud/android/domain/authentication/oauth/model/TokenRequest.kt#L41felix-schwarz commentedon Jul 31, 2022
@TuxCoder One could argue that
offline_accessimplies thatrefresh_tokenrequests must work because theOAuth 2.0 Refresh Tokentobe issued…can be used to obtain an Access Token that grants access– which is only possible with arefresh_tokenrequest.But in the end, the specs IMO leave room for interpretation here, with good arguments for why
["authorization_code","refresh_token"]should be sent - and whyrefresh_tokencould also be omitted.From a practical point of view: are there any OIDC implementations requiring that none, only one - or both be sent?
TuxCoder commentedon Jul 31, 2022
Hello again,
IMHO it's pretty clear a upper standard can not invalid a lower standard,
as OIDC is build on top of OAuth2, OIDC should not invalid Oauth2 standard.
I tested my patched client with the keyclock test system[1] and looks to work.
also login on [2] works, this should be the owncloud one.
[1] https://ocis.ocis-keycloak.latest.owncloud.works/
[2] https://ocis.ocis-wopi.latest.owncloud.works
OCIS IDP:
has no dynamic client registration
at list I don't see one int the configuration file: https://ocis.ocis-wopi.latest.owncloud.works/.well-known/openid-configuration
Ory/Hydra:
Does it IMHO correct, you need to request the
grant_types" : [ "authorization_code", "refresh_token"],Keyclock:
keyclock has not even a setting to restrict refresh_token grant,
it does implement the dynamic client registration invalid:
Also scopes are different than in the app requested.
{ "backchannel_logout_session_required" : false, "client_id" : "9d4ee5ca-36ee-42bd-9934-1c79f3c5eda2", "client_id_issued_at" : 1659277881, "client_name" : "test cli", "client_secret" : "X2N3rqsdk7suSorR8JogVWMYcOKzGFEp", "client_secret_expires_at" : 0, "frontchannel_logout_session_required" : false, "grant_types" : [ "authorization_code", "refresh_token" ], "redirect_uris" : [ "localhost:8080/callback" ], "registration_access_token" : "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJmMTg4OTgzOS1mZGIxLTRjM2EtOThiNi0xMzMwNWYxYjBmNzQifQ.eyJleHAiOjAsImlhdCI6MTY1OTI3Nzg4MSwianRpIjoiMWM2N2ZiMjAtZTkyMC00OWY2LWE3ZTYtZDM2MjYxZDRjYWFhIiwiaXNzIjoiaHR0cHM6Ly9rZXljbG9hay5vY2lzLWtleWNsb2FrLmxhdGVzdC5vd25jbG91ZC53b3Jrcy9hdXRoL3JlYWxtcy9vQ0lTIiwiYXVkIjoiaHR0cHM6Ly9rZXljbG9hay5vY2lzLWtleWNsb2FrLmxhdGVzdC5vd25jbG91ZC53b3Jrcy9hdXRoL3JlYWxtcy9vQ0lTIiwidHlwIjoiUmVnaXN0cmF0aW9uQWNjZXNzVG9rZW4iLCJyZWdpc3RyYXRpb25fYXV0aCI6ImFub255bW91cyJ9.w6HACiPOpNKvDMp8zC3iddD4Jrcpdad7FUlWgqaggWs", "registration_client_uri" : "https://keycloak.ocis-keycloak.latest.owncloud.works/auth/realms/oCIS/clients-registrations/openid-connect/9d4ee5ca-36ee-42bd-9934-1c79f3c5eda2", "request_uris" : [], "require_pushed_authorization_requests" : false, "response_types" : [ "code", "none" ], "scope" : "address phone offline_access microprofile-jwt", "subject_type" : "public", "tls_client_certificate_bound_access_tokens" : false, "token_endpoint_auth_method" : "client_secret_basic" }DeepDiver1975 commentedon Jun 29, 2026
confirmed-bug — still present on
master. The dynamic client registration request is incomplete.Verified in
ClientRegistrationParams.toRequestBody()(built into the POST body byRegisterClientRemoteOperation). The registration request sends only four members:{ "application_type": "...", "client_name": "...", "redirect_uris": [ ... ], "token_endpoint_auth_method": "..." }It does not send
grant_types. Per RFC 7591 the default when omitted is["authorization_code"]only. But the app's token layer issuesgrant_type=refresh_token(TokenRequest.kt), so on a strict IdP (e.g. Ory/Hydra) that enforces the registered grant set, the refresh-token exchange is rejected becauserefresh_tokenwas never registered. The discussion confirmed this against Hydra; lenient IdPs (Keycloak, ocis-idp without DCR) happen to default to both grants, masking the bug.scopeis also omitted: RFC 7591 says the server MAY assign a default set, which need not includeoffline_access— and the Keycloak example in this thread came back withaddress phone offline_access microprofile-jwt, i.e. scopes unrelated to what the app needs.Minimal fix consistent with the spec discussion: add
grant_types: ["authorization_code","refresh_token"](matching the refresh-token usage the app actually performs) andscope: "openid offline_access email profile"to the registration body.response_types/token_endpoint_auth_methoddefaults are acceptable to leave as-is.This is a triage analysis only — no fix PR is being opened from here.
🤖 Generated with Claude Code