No release in over a year
A Zeus WPI strategy for OmniAuth 1.x. This allows you to login to Zauth with your ruby app.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Gem Version

OmniAuth Zeus WPI Zauth Strategy

Strategy to authenticate with Zeus WPI via OAuth2 in OmniAuth, powered by Zauth.

Installation

Add to your Gemfile

gem 'omniauth-oauth2'
gem 'omniauth-zeuswpi'
gem 'omniauth-rails_csrf_protection'

And run bundle install

Usage

Note: Change User to your specific User model

  1. Add the strategy to the omniauth config:
config.omniauth :zeuswpi,
  Rails.application.credentials.omniauth_client_id,
  Rails.application.credentials.omniauth_client_secret,
  token_params: { parse: :json }
  1. Add a callbacks controller:
class CallbacksController < Devise::OmniauthCallbacksController
  # See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
  skip_before_action :verify_authenticity_token, only: :zeuswpi

  def zeuswpi
    @user = User.from_omniauth(request.env["omniauth.auth"])
    sign_in_and_redirect @user, event: :authentication
  end

  def after_omniauth_failure_path_for(scope)
    root_path
  end
end
  1. Add the Devise Omniauth routes:
devise_for :users, controllers: {
  omniauth_callbacks: 'callbacks'
}
  1. Make your User model omniauthable:
devise :omniauthable, omniauth_providers: %i[zeuswpi]
  1. Add the from_omniauth helper to your User model:
def self.from_omniauth(auth)
  where(name: auth.uid).first_or_create do |user|
    user.name = auth.uid
  end
end
  1. Add a button to your website:
<%= button_to "Log in with Zeus WPI",
              user_zeuswpi_omniauth_authorize_path %>