0.0
No commit activity in last 3 years
No release in over 3 years
Uses existing oauth services to authenticate
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.2.3
 Project Readme

OauthService

Uses Google, Yandex Oauth2 services to authenticate users.

##Installation Use rails g oauth_service:install to install basic config

Set all Oauth2 variables in OauthService.providers_keys

config.providers_keys = {
    :google => {
      :auth_url => ENV["GOOGLE_AUTH_URL"],
      :client_id => ENV["GOOGLE_CLIENT_ID"],
      :client_secret => ENV["GOOGLE_CLIENT_SECRET"],
      :info_url => ENV["GOOGLE_INFO_URL"],
      :scopes => ENV["GOOGLE_SCOPES"],
      :token_url => ENV["GOOGLE_TOKEN_URL"]
    }
}

Set all Oauth2 services to allow the following urls: <your_server_name>/<OauthService.redirect_uri>/<provider_name_downcased>?format=<format_name>

OauthService.redirect_uri should be changed according to <your_mount_path>

Set return format using OauthService.request_format. Default is "json"

##How to use

Authentication process

  1. User clicks a link created by <your_provider>.auth_uri

  2. User is sent to oauth service authentication page

  3. After authentication user is sent to link generated by method

  4. Server retrieves all relevant user information

  5. user_name, user_email, api are saved in session.

  6. user_name, user_email variables are returned

Logout process

  1. User is sent to <your_server_name>/<your_mount_path>/logout

  2. user_name, user_email, api are removed from session.

##Creating new Oauth providers To create a new provider you need:

  1. Create a class which inherits from OauthService::Provider

  2. Override OauthService::Provider.get_info

  3. Add your provider keys to OauthService.providers_keys

  4. Add your provider class to OauthService.avaliable_providers