omniauth-spid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.md +7 -0
- data/README.md +78 -0
- data/lib/omniauth/strategies/spid.rb +48 -0
- data/lib/omniauth-spid/version.rb +5 -0
- data/lib/omniauth-spid.rb +2 -0
- data/omniauth-spid.gemspec +27 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c1418af62253844a7a8c3e152de3fee2d33de9b4
|
4
|
+
data.tar.gz: 53f5aa4c49f06efd108f35952ad2f270e660f7a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bade4976b97d41408d65b2115e36efa240db41eca08591cc39e7170229b6c3459a4f130de76e60565639b73151e888e4783fa23bc12835862e027b9b06b85b85
|
7
|
+
data.tar.gz: 2a777be720aca8bbc7553bacd05c3752ddae0aa3575f607f7557ac6867f5d26bca9e8d93f371f8cb5ca6ad0d7f698e385c6695eff06aec7cc59ef554c2ba1b3b
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (C) 2015 R. Arruda and Plendit AS.
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# OmniAuth SPiD
|
2
|
+
|
3
|
+
This is an unofficial OmniAuth strategy for authenticating to SPiD. To
|
4
|
+
use it, you'll need to sign up for an OAuth2 Application ID and Secret
|
5
|
+
with SPiD.
|
6
|
+
|
7
|
+
SPiD stands for Schibsted Payment ID.
|
8
|
+
|
9
|
+
The company offering the SPiD service is Schibsted Payment AS, a
|
10
|
+
subsidiary of Schibsted ASA.
|
11
|
+
|
12
|
+
## Basic Usage
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
use OmniAuth::Builder do
|
16
|
+
provider :spid, ENV['SPID_KEY'], ENV['SPID_SECRET']
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
Note: by default it will connect to the Norwegian staging API:
|
21
|
+
|
22
|
+
`https://stage.payment.schibsted.no/api/2`
|
23
|
+
|
24
|
+
## Using in Production
|
25
|
+
|
26
|
+
You need to override the site value to point to the correct production API url.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
provider :spid, ENV['SPID_KEY'], ENV['SPID_SECRET'],
|
30
|
+
{
|
31
|
+
:client_options => {
|
32
|
+
:site => ENV['SPID_BASE_URL']
|
33
|
+
}
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
## Auth Hash
|
38
|
+
|
39
|
+
Here's an example of an authentication hash available in the callback by accessing request.env["omniauth.auth"]:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
{
|
43
|
+
:provider => "spid",
|
44
|
+
:uid => "123456789",
|
45
|
+
:info => {
|
46
|
+
:nickname => "John Doe",
|
47
|
+
:email => "john@company_name.com",
|
48
|
+
:name => "John Doe",
|
49
|
+
:first_name => "John",
|
50
|
+
:last_name => "Doe",
|
51
|
+
:image => "https://secure.gravatar.com/avatar/1b19ea6c3e4033d54bfcb14d0f8b814a?s=200",
|
52
|
+
:url => ""
|
53
|
+
},
|
54
|
+
:credentials => {
|
55
|
+
:token => "token",
|
56
|
+
:refresh_token => "another_token",
|
57
|
+
:expires_at => 1354920555,
|
58
|
+
:expires => true
|
59
|
+
},
|
60
|
+
:extra => {
|
61
|
+
:raw_info => {
|
62
|
+
(...)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
```
|
67
|
+
|
68
|
+
The information in :raw_info is documented at http://techdocs.spid.no/endpoints/GET/me/
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
Copyright (c) 2015 R. Arruda and Plendit AS.
|
73
|
+
|
74
|
+
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:
|
75
|
+
|
76
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
77
|
+
|
78
|
+
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,48 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Spid < OmniAuth::Strategies::OAuth2
|
6
|
+
# Give your strategy a name.
|
7
|
+
option :name, "spid"
|
8
|
+
|
9
|
+
# This is where you pass the options you would pass when
|
10
|
+
# initializing your consumer from the OAuth gem.
|
11
|
+
option :client_options, {:site => 'https://stage.payment.schibsted.no/api/2'}
|
12
|
+
|
13
|
+
# These are called after authentication has succeeded. If
|
14
|
+
# possible, you should try to set the UID without making
|
15
|
+
# additional calls (if the user id is returned with the token
|
16
|
+
# or as a URI parameter). This may not be possible with all
|
17
|
+
# providers.
|
18
|
+
uid{ raw_info['userId'] }
|
19
|
+
# without making any additional calls:
|
20
|
+
#uid{ @access_token['user_id'] }
|
21
|
+
|
22
|
+
info do
|
23
|
+
{
|
24
|
+
:nickname => raw_info['displayName'],
|
25
|
+
:email => raw_info['email'],
|
26
|
+
:name => raw_info['name']['formatted'],
|
27
|
+
:first_name => raw_info['name']['givenName'],
|
28
|
+
:last_name => raw_info['name']['familyName'],
|
29
|
+
:image => raw_info['photo'],
|
30
|
+
:url => raw_info['url']
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
extra do
|
35
|
+
{
|
36
|
+
'raw_info' => raw_info
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def raw_info
|
41
|
+
access_token.options[:mode] = :query
|
42
|
+
access_token.options[:param_name] = :oauth_token
|
43
|
+
|
44
|
+
@raw_info ||= access_token.get('me').parsed['data']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-spid/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["R. Arruda"]
|
6
|
+
gem.email = ["rarruda@plendit.com"]
|
7
|
+
gem.description = %q{UnOfficial OmniAuth strategy for SPiD.}
|
8
|
+
gem.summary = %q{UnOfficial OmniAuth strategy for SPiD.}
|
9
|
+
gem.homepage = "https://github.com/plendit/omniauth-spid"
|
10
|
+
gem.license = "MIT"
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = "omniauth-spid"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = OmniAuth::Spid::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
20
|
+
# Nothing lower than omniauth-oauth2 1.1.1
|
21
|
+
# http://www.rubysec.com/advisories/CVE-2012-6134/
|
22
|
+
gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
24
|
+
gem.add_development_dependency 'rack-test'
|
25
|
+
#gem.add_development_dependency 'simplecov'
|
26
|
+
#gem.add_development_dependency 'webmock'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-spid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- R. Arruda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-01 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
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.7'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rack-test
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: UnOfficial OmniAuth strategy for SPiD.
|
76
|
+
email:
|
77
|
+
- rarruda@plendit.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.md
|
84
|
+
- README.md
|
85
|
+
- lib/omniauth-spid.rb
|
86
|
+
- lib/omniauth-spid/version.rb
|
87
|
+
- lib/omniauth/strategies/spid.rb
|
88
|
+
- omniauth-spid.gemspec
|
89
|
+
homepage: https://github.com/plendit/omniauth-spid
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: UnOfficial OmniAuth strategy for SPiD.
|
113
|
+
test_files: []
|