Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

OmniAuth strategy to use our Backoffice as an authentication method.

Notifications You must be signed in to change notification settings

10Pines/omniauth-backoffice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

⚠️⚠️⚠️ IMPORTANTE: esta gema está deprecada porque fue reemplazada por una implementación de Oauth directamente en el backoffice. Ver repo de backoffice para más info ⚠️⚠️⚠️

Omniauth-backoffice

10Pines's Backoffice Strategy for OmniAuth.

Installing

Add to your Gemfile:

gem 'omniauth-backoffice', git: 'https://github.com/10pines/omniauth-backoffice.git'

then run bundle install.

Usage

OmniAuth::Strategies::Backoffice is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :backoffice, app_id: "MY_APP_ID", secret: "MY_SECRET", backoffice_url: "https://backoffice.com", callback_path: "/auth/backoffice/callback"
end

Configuring

You need to set a few attributes, which you pass in to the provider method via a Hash:

Option name Explanation
app_id Your app's id from Backoffice
secret Your app's secret from Backoffice
backoffice_url Absolute URL to the backoffice
callback_path You app's OmniAuth callback path for the Backoffice strategy

Failure

The strategy will call OmniAuth's fail! method if something goes wrong on the authentication (i.e. user denying the authentication at the backoffice). To handle these cases, you can set the on_failure block when initializing the OmniAuth::Builder and handle the request inside one of your own controllers.

Rails.application.config.middleware.use OmniAuth::Builder do
  on_failure { |env| OmniAuthController.action(:failure).call(env) }
end

Auth Hash

Auth Hash structure available in request.env['omniauth.auth']:

{
  provider: 'backoffice',
  uid: '1234567',
  info: {
    email: 'user@user.com',
    name: 'Super User',
    nickname: 'myusername',
    user_token: 'adagagagsdbah3141h1'
  },
  extra: {
    root: true
  }
}

About

OmniAuth strategy to use our Backoffice as an authentication method.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages