All Projects → doorkeeper-gem → Doorkeeper Provider App

doorkeeper-gem / Doorkeeper Provider App

An example OAuth 2 provider application using the Doorkeeper gem, Rails and Devise

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Doorkeeper Provider App

Doorkeeper
Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.
Stars: ✭ 4,917 (+3267.81%)
Mutual labels:  ruby-on-rails, oauth2, oauth2-server, oauth2-provider
Flask Oauthlib
YOU SHOULD USE https://github.com/lepture/authlib
Stars: ✭ 1,429 (+878.77%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Light Oauth2
A fast, light and cloud native OAuth 2.0 authorization microservices based on light-4j
Stars: ✭ 247 (+69.18%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+1854.79%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Devise masquerade
Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.
Stars: ✭ 380 (+160.27%)
Mutual labels:  rails, ruby-on-rails, devise
Example Oauth2 Server
Example for OAuth 2 Server for Authlib.
Stars: ✭ 499 (+241.78%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Oauth2
OAuth 2.0 server library for the Go programming language.
Stars: ✭ 2,173 (+1388.36%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+8039.73%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Oauth2 Server
OAuth2 Server Library
Stars: ✭ 42 (-71.23%)
Mutual labels:  oauth2, oauth2-server, oauth2-provider
Instuigram
🎓 Learning Ruby on Rails through building the Instagram Application.
Stars: ✭ 88 (-39.73%)
Mutual labels:  rails, ruby-on-rails, devise
Pingcrm
PingCRM on Rails - A Ruby on Rails demo application to illustrate how Inertia.js works
Stars: ✭ 106 (-27.4%)
Mutual labels:  rails, ruby-on-rails
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-31.51%)
Mutual labels:  rails, devise
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+833.56%)
Mutual labels:  rails, ruby-on-rails
Sr mini
A single file Rails app that will have you running a StimulusReflex and CableReady demo in just 2 steps.
Stars: ✭ 98 (-32.88%)
Mutual labels:  rails, ruby-on-rails
Django Oauth2 Server
OAuth2 server written in Python with Django
Stars: ✭ 108 (-26.03%)
Mutual labels:  oauth2, oauth2-server
Rails api auth
Lightweight Rails Engine that implements the "Resource Owner Password Credentials Grant" OAuth 2.0 flow as well as Facebook authentication
Stars: ✭ 143 (-2.05%)
Mutual labels:  rails, oauth2
Active record Events
Manage timestamps in ActiveRecord models
Stars: ✭ 109 (-25.34%)
Mutual labels:  rails, ruby-on-rails
Simple token authentication
Simple (but safe) token authentication for Rails apps or API with Devise.
Stars: ✭ 1,474 (+909.59%)
Mutual labels:  rails, devise
Reactchat
A chat app built with React.js and ActionCable in Ruby on Rails 5.1
Stars: ✭ 90 (-38.36%)
Mutual labels:  rails, ruby-on-rails
Gdpr Rails
An example project on building a GDPR compliant application
Stars: ✭ 109 (-25.34%)
Mutual labels:  rails, ruby-on-rails

Doorkeeper Provider App

Build Status Build Status

This app is an example of an OAuth 2 provider using Doorkeeper gem, Rails 5.2 and Devise. Check out the app hosted on heroku for a live demo.

About Doorkeeper Gem

For more information about the gem, documentation, wiki and another resources, check out the project on GitHub

Installation

First clone the repository from GitHub:

git clone git://github.com/doorkeeper-gem/doorkeeper-provider-app.git

Install all dependencies with:

bundle install

After that you're almost ready to go.

Configuration

The configuration is quite simple, all you need to do is run:

bundle exec rake db:setup

This will generate all necessary tables, create fake data, create an user and a client application.

Seed data

The generated user email is [email protected] and password is doorkeeper.

The application id and secret will show up on terminal when the script ends.

After that, you can just fire up the rails server and you're ready to go.

OAuth Endpoint

The endpoints is mounted under /oauth so our routes look like this:

GET       /oauth/authorize
POST      /oauth/authorize
DELETE    /oauth/authorize
POST      /oauth/token
resources /oauth/applications

Example API

This app provides a sample JSON API under /api/v1. The current API endpoints are:

/api/v1/profiles.json
/api/v1/me.json

In routes.rb you can check out how they're made:

namespace :api do
  namespace :v1 do
    resources :profiles
    get '/me' => "credentials#me"
  end
end

We namespace the API controllers to avoid name clashing and collisions between your existing application and the API. This way, you can make changes to your application without messing up with the API's behavior.

You can find all controllers under /app/controllers/api/v1 folder.

The api_controller.rb works as a parent class to the other controllers. It only defines a method that returns the current resource owner, based on the access token:

def current_resource_owner
  User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end

This is required if you want to return data based on the current user, like in credentials_controller.rb

Make Access Token Required

To make your API only available for OAuth users, you need to tell doorkeeper to require an access token in your api controller, like this:

module Api::V1
  class ProfilesController < ApiController
    before_action :doorkeeper_authorize!

    def index
      render json: Profile.recent
    end
  end
end

However, see also the Doorkeeper wiki article about using scopes.

If you attempt to access any of the protected resources without an proper access token, you'll get an 401 Unauthorized response.

Client applications

You can manage all client applications in /oauth/applications.

If you want to create a client application, check out this example using Sinatra and this another one using Rails and Devise.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].