omniauth-cisimple 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.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OmniAuth Cisimple
2
+
3
+ This is the official OmniAuth strategy for authenticating to cisimple. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Cisimple Applications Page](https://cisimple.com/).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :cisimple, ENV['CISIMPLE_KEY'], ENV['CISIMPLE_SECRET']
11
+ end
12
+
13
+ ## License
14
+
15
+ Copyright (c) 2013 cisimple
16
+
17
+ MIT License
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining
20
+ a copy of this software and associated documentation files (the
21
+ "Software"), to deal in the Software without restriction, including
22
+ without limitation the rights to use, copy, modify, merge, publish,
23
+ distribute, sublicense, and/or sell copies of the Software, and to
24
+ permit persons to whom the Software is furnished to do so, subject to
25
+ the following conditions:
26
+
27
+ The above copyright notice and this permission notice shall be
28
+ included in all copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'omniauth-cisimple/version'
2
+ require 'omniauth/strategies/cisimple'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Cisimple
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,91 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Cisimple < OmniAuth::Strategies::OAuth2
6
+ class NoAuthorizationCodeError < StandardError; end
7
+
8
+ option :client_options, {
9
+ :site => 'https://cisimple.com',
10
+ :authorize_url => 'https://cisimple.com/login/oauth/authorize',
11
+ :token_url => 'https://cisimple.com/login/oauth/access_token'
12
+ }
13
+
14
+ def request_phase
15
+ super
16
+ end
17
+
18
+ option :access_token_options, {
19
+ :param_name => 'access_token'
20
+ }
21
+
22
+ def authorize_params
23
+ super.tap do |params|
24
+ %w[scope client_options].each do |v|
25
+ if request.params[v]
26
+ params[v.to_sym] = request.params[v]
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ uid { raw_info['id'].to_s }
33
+
34
+ info do
35
+ {
36
+ 'email' => email,
37
+ 'image' => image,
38
+ 'nickname' => nickname
39
+ }
40
+ end
41
+
42
+ def raw_info
43
+ access_token.options[:mode] = :query
44
+ @raw_info ||= access_token.get('user').parsed
45
+ end
46
+
47
+ def access_token_options
48
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
49
+ end
50
+
51
+ def build_access_token
52
+ if access_token = request.params["access_token"]
53
+ ::OAuth2::AccessToken.from_hash(
54
+ client,
55
+ {"access_token" => access_token}.update(access_token_options)
56
+ )
57
+ else
58
+ with_authorization_code! { super }.tap do |token|
59
+ token.options.merge!(access_token_options)
60
+ end
61
+ end
62
+ end
63
+
64
+ def with_authorization_code!
65
+ if request.params.key?('code')
66
+ yield
67
+ else
68
+ raise NoAuthorizationCodeError, 'must pass code parameter'
69
+ end
70
+ end
71
+
72
+ def email
73
+ raw_info['email']
74
+ end
75
+
76
+ def image
77
+ raw_info['avatar_url']
78
+ end
79
+
80
+ def nickname
81
+ raw_info['nickname']
82
+ end
83
+
84
+ def email_access_allowed?
85
+ options['scope'] =~ /user/
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-cisimple
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Justice
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: omniauth
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: omniauth-oauth2
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.1'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.1'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.7'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.7'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rack-test
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Omniauth plugin for cisimple
143
+ email:
144
+ - david@cisimple.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - README.md
150
+ - lib/omniauth-cisimple.rb
151
+ - lib/omniauth-cisimple/version.rb
152
+ - lib/omniauth/strategies/cisimple.rb
153
+ homepage: https://github.com/cisimple-team/omniauth-cisimple
154
+ licenses:
155
+ - MIT
156
+ post_install_message:
157
+ rdoc_options:
158
+ - --charset=UTF-8
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ segments:
168
+ - 0
169
+ hash: -404938446564416868
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ segments:
177
+ - 0
178
+ hash: -404938446564416868
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 1.8.24
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: Omniauth plugin for cisimple
185
+ test_files: []