Skip to content

Browser-based client login #24794

Closed
Closed

Description

@ChristophWurst

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.

ref owncloud/client#4798

cc @danimo @PVince81 @DeepDiver1975 @MTRichards @butonic @LukasReschke @owncloud/desktop-developers @owncloud/android-developers @owncloud/ios-developers

Activity

  1. added this to the milestone on May 24, 2016
  2. PVince81 commented on May 24, 2016

    @PVince81
    Contributor

    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:

    • basic auth (legacy)
    • token-based auth using browser login

    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.

  3. rullzer commented on May 24, 2016

    @rullzer
    Contributor

    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 ;)

  4. guruz commented on May 24, 2016

    @guruz
    Contributor

    @rullzer In general I agree, but then how can people easily use curl, davfs, file managers etc?

  5. ChristophWurst commented on May 24, 2016

    @ChristophWurst
    ContributorAuthor

    @guruz you can use the generated token as password, so basic auth user:token works.

  6. rullzer commented on May 24, 2016

    @rullzer
    Contributor

    Exactly they have to generate device tokens on the webinterface...

  7. 24 remaining items

  8. michaelstingl commented on Dec 7, 2016

    @michaelstingl

    I think this is obsoleted by OAuth2 ?

    @butonic @pmaier1 Could you help here?

  9. butonic commented on Dec 7, 2016

    @butonic
    Contributor

    yes

  10. DeepDiver1975 commented on Dec 7, 2016

    @DeepDiver1975
    Contributor

    why close?

  11. DeepDiver1975 commented on Dec 7, 2016

    @DeepDiver1975
    Contributor

    A PR was started on this - #26742

  12. PVince81 commented on Apr 7, 2017

    @PVince81
    Contributor

    that PR was merged, what's left ?

  13. PVince81 commented on Apr 7, 2017

    @PVince81
    Contributor

    likely still a lot to do.

  14. pmaier1 commented on Apr 7, 2017

    @pmaier1
    Contributor

    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.

  15. PVince81 commented on May 15, 2017

    @PVince81
    Contributor

    obsolete ?

  16. lock commented on Aug 2, 2019

    @lock

    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.

  17. locked as resolved and limited conversation to collaborators on Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions