Description
Overview
With some identity providers (e.g. shibboleth SSO), the user logs in on an external web page which on success authenticates the user for ownCloud. As the client needs a browser window for that and desktop clients are planning to remove those (see owncloud/client#4798), we need to find a generic way to authenticate clients on external services and create a device token if the authentication succeeds. Instead of a built-in browser an external one should be used.
Basic workflow
Step 1. Determine auth mechanism
- C -> S: Client sends unauthenticated request to a defined endpoint E1
- S -> C: Server responds with a list of possible auth mechanisms (basic, token, browser-based)
If basic auth is used -> send HTTP header 'Authentication: basic username:password'
If token auth is used -> send HTTP header 'Authentication: basic username:token' or 'Authentication: token xxx' if #24763 was implemented.
Step 2. Request login URL + temporary token
- C -> S: Client requests URL + token from defined endpoint E2 (and specifies provider?)
- Server creates temporary token and saves it to the DB
- S -> C: Server returns URL for the external browser and the temporary token
Note: the URL must contain the temporary token, so that the identity provider redirects the user back after successful login (or if the user was already logged in).
Step 3a. Open browser window for user and let her/him authenticate
- Client opens browser window and shows the URL returned by the server
- User logs in on that page, which then redirects back to a defined endpoint E3
- On the redirected endpoint, the database entry of the temporary token is updated to reflect the login status
Step 3b. Polling the auth state from the server
- C -> S: In the background, the client polls the server on a defined endpoint E4 using the temporary token
- S -> C: As soon as the login was finished, the server creates a device token (app specific password) and returns it. The temporary token/database entry can be deleted.
Step 4. Use the token
- The returned token can then be used for authenticating requests (sent as header)
This will also allow to connect sync clients to accounts which are two-factor enforced. There we can use ownCloud itself as 'identity provider' and let the user solve the 2FA challenge.
We could even go one step further and do the login purely in a browser, even if no 2FA or special identity provider is used. This would be an interesting login mechanism for untrustworthy clients you don't want to enter your password.
HTTP workflow
Requesting auth mechanisms/providers:
C -> S GET owncloud/auth/test
C <- S 401 (+ list of providers)
C -> S POST owncloud/auth/provider (+ provider id?)
C <- S 200 URL + temp token
Login in external browser:
C -> ID GET identityprovider/login
C <- ID 200 login form
C -> ID POST idendityprovider/login
C <- ID 302/303 owncloud/auth/auth/finish
Meanwhile, polling the server:
C -> S GET owncloud/auth/status?token=xxx
C <- C 200 status, either 'pending' or 'finished' + new device token
Issues
- The identity provider is only asked once, hence killing a session with that provider will not log the client out.
cc @danimo @PVince81 @DeepDiver1975 @MTRichards @butonic @LukasReschke @owncloud/desktop-developers @owncloud/android-developers @owncloud/ios-developers
Activity
PVince81 commentedon May 24, 2016
I think the client doesn't need to know about how the web UI logs itself in, it doesn't interest the client.
Basically there are only two authentication methods:
In the case of browser login, the client connects to the server and the server returns a constant URL, for example "https://host/owncloud/loginsuccess". This page itself requires log in, so opening it as an unauthenticated user will automatically trigger the existing authentication mechanism (SSO, 2-factor, whichever). This already exists and doesn't need additional work and doesn't require the client to know that there's SSO or 2-factor.
Then, as soon as the user is authorized to open the "loginsucess" page, that page internally creates the real auth token and makes it available through the polling endpoint.
In some cases, the user already has an authenticated browser of the same type, so opening the URL "loginsuccess" will directly generate the token without requiring additional login.
rullzer commentedon May 24, 2016
I would even go a step further and force clients to use the weblogin method. That way only tokens are used to secure our users. And since it is all async without real user involement those tokens can be huge by default :)
Now of course the client will need to support basic auth for quite some time still (since we support older servers). But a simple check against status.php could disable basic auth by definition.
We want users to use tokens by default so don't give them a choice ;)
guruz commentedon May 24, 2016
@rullzer In general I agree, but then how can people easily use curl, davfs, file managers etc?
ChristophWurst commentedon May 24, 2016
@guruz you can use the generated token as password, so basic auth user:token works.
rullzer commentedon May 24, 2016
Exactly they have to generate device tokens on the webinterface...
ChristophWurst commentedon May 25, 2016
This seems to be the workflow we aim for: https://en.wikipedia.org/wiki/OAuth#OpenID_vs._pseudo-authentication_using_OAuth
24 remaining items
michaelstingl commentedon Dec 7, 2016
@butonic @pmaier1 Could you help here?
butonic commentedon Dec 7, 2016
yes
DeepDiver1975 commentedon Dec 7, 2016
why close?
DeepDiver1975 commentedon Dec 7, 2016
A PR was started on this - #26742
PVince81 commentedon Apr 7, 2017
that PR was merged, what's left ?
PVince81 commentedon Apr 7, 2017
likely still a lot to do.
pmaier1 commentedon Apr 7, 2017
As soon as we have oAuth2 ready on server- and client-side clients should just use oAuth2 and should not have to tamper with anything else anymore.
PVince81 commentedon May 15, 2017
obsolete ?
lock commentedon Aug 2, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.