Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

omniauth-classiclaw-oauth2

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

omniauth-classiclaw-oauth2

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

OmniAuth Classiclaw Data Platform OAuth2

数据生产平台OAuth授权

Installing

Add to your Gemfile:

gem 'omniauth-classiclaw-oauth2', git: 'ssh://git@git.classiclaw.com:2020/data_platform/omniauth-classiclaw-oauth2.git'

Then bundle install

Usage

OmniAuth::Strategies::Classiclaw is simply a Rack middleware. Read the OmniAuth 1.0 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 :classiclaw, ENV['PLATFORM_APPID'], ENV['PLATFORM_SECRET'], client_options: {
    site: ENV['PLATFORM_URL']
  }
end

Configuration

you can set up redirect_uri in omniauth.rb as following:

provider :classiclaw, ENV['PLATFORM_APPID'], ENV['PLATFORM_SECRET'], client_options: {
  site: ENV['PLATFORM_URL']
}

Authentication Hash

{
  :provider => 'classiclaw',
  :uid => '1234567890',
  :info => {
    :name => '张三',
    :email => 'tester@t.com',
    :court_id => 215,
    :dlbs => 'tester',
    :rybs => 'tester'
  },
  :extra => {
    :raw_info => {
    	'uid' => '1234567890',
       'name' => '张三',
       'court_id' => 215, # 默认曲阳县人民法院
       'dlbs' => 'tester',
       'rybs' => 'tester'
    }
  }
}

Rails

Add a callback route to config/routes.rb

get '/auth/:provider/callback', to: 'sessions#create'

Create the SessionsController

class SessionsController < ApplicationController
  def create
    @user = User(request.env['omniauth.auth'])
    session['current_user_id'] = @user.id
    redirect_to root_path
  end
end

For your views you can login using:

<%= link_to "Sign in with Data Platform", '/auth/classiclaw' %>

TODO

  1. get real user info and return to the Authentication Hash

FAQs

Package last updated on 30 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc