Skip to content

DCrow/oauth_service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Authentication for Rails using Oauth services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published