omniauth-nctu 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f9e837b7c08f8f1668403c03662ce0ab5d79f2c
4
- data.tar.gz: cec7153d1d48f2a9081c2d84fcead947572040e2
3
+ metadata.gz: ec20404fb79a769de42f06583db429c11b5decb1
4
+ data.tar.gz: 192ac2d6546ff81c1fd35c9fd305f4d03476af69
5
5
  SHA512:
6
- metadata.gz: 0bb3a62adfc0d1a5a6a668e158f71450055ab125f4e3763d57ca9a89581c133e6514f80c0a3fb4d7493e2ac2a24e91222422731d79db9b406cd8596626d9fc57
7
- data.tar.gz: 6e623b2da700a3126aeb8ec7d6662857684ab6cd18f33da1dae6396ef1b8eb6dd9756d67d259219b8196ce4671b2c9b2b2aa97b347a7dd3394d68211aa78744a
6
+ metadata.gz: c7f83c70977c1379adb7ca82a1acafed3ce27a7c69b5f116ddcf0db84f1b1d00fd9aaf188eecbdc34fbb6577f2543909353401b39302dc0d31bac5488582d5e8
7
+ data.tar.gz: 56d93de1e712afdd20d560f92914d95dc58a59d5c3ae4d1189766aa7ee0eacbebf7d7ef4faed3f9eb80184f56a38bccfc57937f964ef8e2df2ff1a86790911b6
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Omniauth::Nctu
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/nctu`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ 使用OmniAuth實作NCTU-Oauth登入認證的Ruby套件
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,19 +18,33 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install omniauth-nctu
22
20
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
21
+ ## Example
28
22
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+ ```ruby
24
+ require 'sinatra'
25
+ require 'omniauth-nctu'
26
+
27
+ use Rack::Session::Cookie
28
+ use OmniAuth::Builder do
29
+ provider :nctu, ENV['NCTU_OAUTH_KEY'], ENV['NCTU_OAUTH_SECRET']
30
+ end
31
+
32
+ get '/' do
33
+ <<-HTML
34
+ <a href='/auth/nctu'>Sign in with NCTU</a>
35
+ HTML
36
+ end
37
+
38
+ get '/auth/nctu/callback' do
39
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
40
+ erb "您好,#{request.env['omniauth.auth'].to_hash["uid"]}。您的D2信箱是#{request.env['omniauth.auth'].to_hash["info"]["d2_email"]}。"
41
+ end
42
+ ```
30
43
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
44
 
33
45
  ## Contributing
34
46
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-nctu.
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/deror1869107/omniauth-nctu.
36
48
 
37
49
 
38
50
  ## License
data/example/config.ru CHANGED
@@ -1,28 +1,19 @@
1
- begin
2
- require 'sinatra'
3
- require 'omniauth'
4
- require 'omniauth-nctu'
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'sinatra'
8
- require 'omniauth'
9
- require 'openid/store/filesystem'
10
- require 'omniauth-nctu'
11
- end
1
+ require 'sinatra'
2
+ require 'omniauth-nctu'
12
3
 
13
- use Rack::Session::Cookie
14
- use OmniAuth::Builder do
15
- provider :nctu, ENV['NCTU_OAUTH_KEY'], ENV['NCTU_OAUTH_SECRET']
16
- end
4
+ use Rack::Session::Cookie
5
+ use OmniAuth::Builder do
6
+ provider :nctu, ENV['NCTU_OAUTH_KEY'], ENV['NCTU_OAUTH_SECRET']
7
+ end
17
8
 
18
- get '/' do
19
- <<-HTML
20
- <a href='/auth/nctu'>Sign in with NCTU</a>
21
- HTML
22
- end
9
+ get '/' do
10
+ <<-HTML
11
+ <a href='/auth/nctu'>Sign in with NCTU</a>
12
+ HTML
13
+ end
23
14
 
24
- get '/auth/nctu/callback' do
25
- request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
26
- # do whatever you want with the information!
27
- erb "您好,#{request.env['omniauth.auth'].to_hash["uid"]}。您的D2信箱是#{request.env['omniauth.auth'].to_hash["info"]["d2_email"]}。"
28
- end
15
+ get '/auth/nctu/callback' do
16
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
17
+ puts request.env['omniauth.auth']
18
+ erb "您好,#{request.env['omniauth.auth'].to_hash["uid"]}。您的D2信箱是#{request.env['omniauth.auth'].to_hash["info"]["d2_email"]}。"
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Nctu
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -14,9 +14,12 @@ module OmniAuth
14
14
  token_url: "#{OAuthUrl}/o/token/"
15
15
  }
16
16
 
17
+ uid do
18
+ raw_info["username"]
19
+ end
20
+
17
21
  info do
18
22
  {
19
- :username => raw_info["username"],
20
23
  :d2_email => raw_info["d2_email"]
21
24
  }
22
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-nctu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuan-Yao Sung
@@ -89,14 +89,11 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
- - ".rspec"
93
92
  - ".travis.yml"
94
93
  - Gemfile
95
94
  - LICENSE.txt
96
95
  - README.md
97
96
  - Rakefile
98
- - bin/console
99
- - bin/setup
100
97
  - example/Gemfile
101
98
  - example/config.ru
102
99
  - lib/omniauth-nctu.rb
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "omniauth/nctu"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here