Coder Social home page Coder Social logo

omniauth-nctu's Introduction

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.

omniauth-nctu's People

Contributors

yysung1123 avatar bananaappletw avatar

Stargazers

Jim Shu avatar Steven Lin avatar  avatar  avatar Billy Su avatar Tony Lin avatar Iblis Lin avatar Bryce Tsao avatar

Watchers

James Cloos avatar  avatar Billy Su avatar

Forkers

vava24680

omniauth-nctu's Issues

Add essential fields into info column

For now, only email field in the info column.
Many OAuth provider implement essential information in the info column.
For example, omniauth-facebook

 info: {
    email: '[email protected]',
    name: 'Joe Bloggs',
    first_name: 'Joe',
    last_name: 'Bloggs',
    image: 'http://graph.facebook.com/1234567/picture?type=square',
    verified: true
  },

In my opinion, you could use uid as name and maybe nctu logo as image field.
Then, developer could use the same logic for different OAuth providers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.