omniauth-ncuportal 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b82ba2d927bc961779b7bd39f04adcfa5d74529e
4
+ data.tar.gz: 33627295afd9d759d08f2a01ecbfc1e6a1f0a7e9
5
+ SHA512:
6
+ metadata.gz: a78d73dc0f185044776d0490315272e40b524c31dceff400f345c1853fce647cf9e1ee335ab0b1167fea45395d5192dea46c354e4910c8002b73077f99acfbe8
7
+ data.tar.gz: 5e7195e390e488fadb533a808ac666839fdd74929c06f0f408f3fa4b5af8d926081e5f3e93f7c66c6c4dc59d01a91d5764989b2cb2f7b9435a55cff50c033ea2
@@ -0,0 +1,10 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ charset = utf-8
9
+ indent_style = space
10
+ indent_size = 2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2015- Community of Networking and Open Source
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'omniauth-ncuportal/version'
2
+ require 'omniauth/strategies/ncuportal'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module NCUPortal
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class NCUPortal < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPES = %w(identifier)
7
+ HOST = 'portal3g.ncu.edu.tw'
8
+
9
+ option :client_options, {
10
+ :site => "https://#{HOST}",
11
+ :authorize_url => "https://#{HOST}/oauth2/authorization",
12
+ :token_url => "https://#{HOST}/oauth2/token"
13
+ }
14
+
15
+ option :token_params, {
16
+ :parse => :json
17
+ }
18
+
19
+ option :authorize_params, {
20
+ :scope => DEFAULT_SCOPES
21
+ }
22
+
23
+ def request_phase
24
+ super
25
+ end
26
+
27
+ def authorize_params
28
+ super.tap do |params|
29
+ %w[scope client_options].each do |v|
30
+ if request.params[v]
31
+ params[v.to_sym] = request.params[v]
32
+ end
33
+ end
34
+ params[:scope] = params[:scope].join ' ' if params[:scope]
35
+ end
36
+ end
37
+
38
+ uid do
39
+ info['id']
40
+ end
41
+
42
+ info do
43
+ {
44
+ 'id' => raw_info['id']
45
+ }
46
+ end
47
+
48
+ extra do
49
+ {
50
+ :raw_info => raw_info
51
+ }
52
+ end
53
+
54
+ def raw_info
55
+ access_token.options[:mode] = :header
56
+ @raw_info ||= access_token.get('apis/oauth/v1/info').parsed
57
+ rescue ::OAuth2::Error => e
58
+ Logger.new(STDOUT).info e.to_s
59
+ {}
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ OmniAuth.config.add_camelization 'ncuportal', 'NCUPortal'
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-ncuportal/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "omniauth-ncuportal"
7
+ gem.version = OmniAuth::NCUPortal::VERSION
8
+ gem.authors = ["David Kuo"]
9
+ gem.email = ["me@davy.tw"]
10
+ gem.homepage = "https://github.com/NCUNOS/omniauth-ncuportal"
11
+ gem.description = %q{OmniAuth gem.rategy for NCU Portal(3g) OAuth.}
12
+ gem.summary = gem.description
13
+ gem.license = "MIT"
14
+
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'omniauth', '~> 1.0'
21
+ gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
22
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-ncuportal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - David Kuo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ description: OmniAuth gem.rategy for NCU Portal(3g) OAuth.
48
+ email:
49
+ - me@davy.tw
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - ".editorconfig"
55
+ - Gemfile
56
+ - LICENSE
57
+ - lib/omniauth-ncuportal.rb
58
+ - lib/omniauth-ncuportal/version.rb
59
+ - lib/omniauth/strategies/ncuportal.rb
60
+ - omniauth-ncuportal.gemspec
61
+ homepage: https://github.com/NCUNOS/omniauth-ncuportal
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.8
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: OmniAuth gem.rategy for NCU Portal(3g) OAuth.
85
+ test_files: []
86
+ has_rdoc: