Coder Social home page Coder Social logo

minhnhut0602 / oauth2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from owncloud/oauth2

0.0 2.0 0.0 363 KB

๐Ÿ” Application for using OAuth 2.0 in ownCloud

License: GNU Affero General Public License v3.0

Makefile 2.56% PHP 79.20% CSS 0.14% JavaScript 18.10%

oauth2's Introduction

๐Ÿ” OAuth 2.0

Build Status codecov

This app implements the OAuth 2.0 Authorization Code Flow.

Installing the app

Place the content of this repository in owncloud/apps/oauth2.

Using the app

Endpoints

  • Authorization URL: /index.php/apps/oauth2/authorize
  • Access Token URL: /index.php/apps/oauth2/api/v1/token

Protocol Flow

  1. Client registration: First the clients have to be registered in the admin settings: /index.php/settings/admin?sectionid=additional#oauth2. You need to specify a name for the client (the name is unrelated to the OAuth 2.0 protocol and is just used to recognize it later) and the redirection URI. A client identifier and client secret is being generated when adding a new client. They both consist of 64 characters.

  2. Authorization Request: For every registered client an Authorization Request can be made. The client redirects the resource owner to the Authorization URL and requests authorization. The following URL parameters have to be specified:

    1. response_type (required): needs to be code because at this time only the Authorization Code Flow is implemented.
    2. client_id (required): the client identifier obtained when registering the client.
    3. redirect_uri (required): the redirection URI specified when registering the client.
    4. state (optional): can be set by the client "to maintain state between the request and callback" (RFC 6749).
  3. Authorization Response: After the resource owner's authorization the app redirects to the redirect_uri specified in the Authorization Request and adds the Authorization Code as URL parameter code. An Authorization Code is valid for 10 minutes.

  4. Access Token Request: With the Authorization Code the client can request an Access Token using the Access Token URL. Client Authentication is done using Basic Auth with the client identifier as username and the client secret as password. The following URL parameters have to be specified:

    1. grant_type : Either authorization_code or refresh_token.
    2. code and redirect_uri (if the grant type authorization_code is used).
    3. refresh_token (if the grant type refresh_token is used).
  5. Access Token Response: The app responses to a valid Access Token Request with an JSON response like the following. An Access Token is valid for 1 hour and can be refreshed with a Refresh Token.

{
    "access_token" : "1vtnuo1NkIsbndAjVnhl7y0wJha59JyaAiFIVQDvcBY2uvKmj5EPBEhss0pauzdQ",
    "token_type" : "Bearer",
    "expires_in" : 3600,
    "refresh_token" : "7y0wJuvKmj5E1vjVnhlPBEhha59JyaAiFIVQDvcBY2ss0pauzdQtnuo1NkIsbndA",
    "user_id" : "admin"
}

Limitations

Since no user passwords are handled by the app at all only master key encryption is working (similiar to the Shibboleth app).

Possible improvements

  • Add option for using different scopes.

oauth2's People

Contributors

joneug avatar lukebier avatar dennismeis avatar tomneedham avatar deepdiver1975 avatar ninaherrmann avatar

Watchers

James Cloos avatar Nhut Phan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.