0.0
No commit activity in last 3 years
No release in over 3 years
This gem is an OmniAuth OAuth2 strategy for NCTU Oauth. NCTU students can use it to signup/login on their apps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0

Runtime

 Project Readme

Omniauth::Nctu

使用OmniAuth實作NCTU-Oauth登入認證的Ruby套件

Installation

Add this line to your application's Gemfile:

gem 'omniauth-nctu'

And then execute:

$ bundle

Or install it yourself as:

$ gem install omniauth-nctu

Example

require 'sinatra'
require 'omniauth-nctu'

use Rack::Session::Cookie
use OmniAuth::Builder do
  provider :nctu, ENV['NCTU_OAUTH_KEY'], ENV['NCTU_OAUTH_SECRET']
end

get '/' do
  <<-HTML
    <a href='/auth/nctu'>Sign in with NCTU</a>
  HTML
end

get '/auth/nctu/callback' do
  request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
  erb "您好,#{request.env['omniauth.auth'].to_hash["uid"]}。您的D2信箱是#{request.env['omniauth.auth'].to_hash["info"]["email"]}。"
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/deror1869107/omniauth-nctu.

License

The gem is available as open source under the terms of the MIT License.