omniauth-swoop 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/omniauth-swoop.rb +1 -1
- data/lib/{omniauth/swoop-version.rb → omniauth-swoop/version.rb} +1 -1
- data/lib/omniauth/strategies/swoop.rb +46 -26
- data/omniauth-swoop.gemspec +7 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73289db6ed53654d18e2f9eb61170635d3ca3bb44c11d25903a103e1049a05c0
|
4
|
+
data.tar.gz: 92183a1d64ff7e7b4dd32032aab0f3de7032bbd29332a87cc036e475919c7738
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe3a6374645bd7f625a1296499d0c9f8dba510a2bc08dfcd415c48d19ca1fd889fe0a55a44b905f2107511e0fe06cc864e5619f2316c37f451b0667189b444b
|
7
|
+
data.tar.gz: 9d96523bb978624ac5060586f98b207c63f758f1f1f623cc3b2e1108c38268adc6aa9674bb41e062ac921607e06176941fb97424bab6c771a4fa275165098ec1
|
data/lib/omniauth-swoop.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'omniauth/strategies/swoop'
|
2
|
-
require 'omniauth/
|
2
|
+
require 'omniauth-swoop/version'
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'omniauth-oauth2'
|
2
|
+
require 'jwt'
|
2
3
|
|
3
4
|
module OmniAuth
|
4
5
|
module Strategies
|
5
6
|
class Swoop < OmniAuth::Strategies::OAuth2
|
6
|
-
|
7
|
-
include OmniAuth::Strategy
|
8
|
-
|
9
7
|
option :name, "swoop"
|
10
8
|
|
11
9
|
option :client_options, {
|
@@ -14,12 +12,7 @@ module OmniAuth
|
|
14
12
|
user_info_url: '/oauth2/profile'
|
15
13
|
}
|
16
14
|
|
17
|
-
option :
|
18
|
-
attributes: {
|
19
|
-
email: 'email',
|
20
|
-
uid: 'sub'
|
21
|
-
}
|
22
|
-
}
|
15
|
+
option :pkce, true
|
23
16
|
|
24
17
|
option :authorize_params, {
|
25
18
|
scope: 'email'
|
@@ -28,15 +21,16 @@ module OmniAuth
|
|
28
21
|
option :redirect_url
|
29
22
|
|
30
23
|
uid do
|
31
|
-
|
24
|
+
info["uid"]
|
32
25
|
end
|
33
26
|
|
34
27
|
info do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
{
|
29
|
+
:uid => raw_info['sub'],
|
30
|
+
:email => raw_info['email'],
|
31
|
+
:user_meta => raw_info['user_meta']
|
32
|
+
}
|
33
|
+
|
40
34
|
end
|
41
35
|
|
42
36
|
extra do
|
@@ -45,26 +39,52 @@ module OmniAuth
|
|
45
39
|
|
46
40
|
def raw_info
|
47
41
|
@raw_info ||= access_token.get(options.client_options[:user_info_url]).parsed
|
48
|
-
|
42
|
+
id_token = access_token.params["id_token"]
|
43
|
+
|
44
|
+
decoded_token = JWT.decode id_token, options.client_secret, true, { algorithm: 'HS256' }
|
45
|
+
|
46
|
+
if(decoded_token[0].key?("user_meta"))
|
47
|
+
@raw_info["user_meta"] = decoded_token[0]["user_meta"]
|
48
|
+
end
|
49
|
+
|
50
|
+
@raw_info["id_token"] = id_token
|
51
|
+
@raw_info
|
49
52
|
end
|
50
53
|
|
51
54
|
def authorize_params
|
52
55
|
params = super
|
53
|
-
Hash[params.map { |k, v| [k, v.respond_to?(:call) ? v.call(request) : v] }]
|
54
|
-
end
|
56
|
+
p = Hash[params.map { |k, v| [k, v.respond_to?(:call) ? v.call(request) : v] }]
|
55
57
|
|
56
|
-
|
58
|
+
request_params = request.params
|
59
|
+
property_meta = {}
|
60
|
+
if request_params.key?("property_method")
|
61
|
+
property_meta["method"] = request_params["property_method"]
|
62
|
+
request_params.delete("property_method")
|
63
|
+
end
|
64
|
+
if request_params.key?("property_name")
|
65
|
+
property_meta["name"] = request_params["property_name"]
|
66
|
+
request_params.delete("property_name")
|
67
|
+
end
|
68
|
+
if request_params.key?("property_logo_url")
|
69
|
+
property_meta["logo_url"] = request_params["property_logo_url"]
|
70
|
+
request_params.delete("property_logo_url")
|
71
|
+
end
|
72
|
+
if request_params.key?("property_primary_color")
|
73
|
+
property_meta["primary_color"] = request_params["property_primary_color"]
|
74
|
+
request_params.delete("property_primary_color")
|
75
|
+
end
|
57
76
|
|
58
|
-
|
59
|
-
|
60
|
-
|
77
|
+
if property_meta.length > 0
|
78
|
+
property_meta = JWT.encode property_meta, options.client_secret, 'HS256'
|
79
|
+
p["property_meta"] = property_meta
|
80
|
+
end
|
61
81
|
|
62
|
-
|
63
|
-
|
64
|
-
full_path = path.is_a?(Array) ? path : Array(user_paths[:root_path]) + [path]
|
65
|
-
full_path.inject(raw_info) { |info, key| info[key] rescue nil }
|
82
|
+
p = p.merge(request_params)
|
83
|
+
p
|
66
84
|
end
|
67
85
|
|
86
|
+
private
|
87
|
+
|
68
88
|
def callback_url
|
69
89
|
options.redirect_url || (full_host + script_name + callback_path)
|
70
90
|
end
|
data/omniauth-swoop.gemspec
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "omniauth-swoop/version"
|
5
|
+
|
2
6
|
Gem::Specification.new do |s|
|
3
7
|
s.name = 'omniauth-swoop'
|
4
|
-
s.version =
|
5
|
-
s.date = '2021-01-
|
8
|
+
s.version = OmniAuth::Swoop::VERSION
|
9
|
+
s.date = '2021-01-21'
|
6
10
|
s.homepage = "https://github.com/swoop-password-free/omniauth-swoop"
|
7
11
|
s.description = %q{OmniAuth strategy for Swoop passwordless authentication}
|
8
12
|
s.summary = s.description
|
@@ -14,5 +18,6 @@ Gem::Specification.new do |s|
|
|
14
18
|
s.require_paths = ["lib"]
|
15
19
|
s.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
|
16
20
|
s.add_dependency 'omniauth-oauth2', '~> 1.7.1'
|
21
|
+
s.add_dependency 'jwt', '~> 2.2.2'
|
17
22
|
s.add_development_dependency 'bundler', '~> 1.0'
|
18
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-swoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Trebitowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.7.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: jwt
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.2.2
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.2.2
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: bundler
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,8 +62,8 @@ files:
|
|
48
62
|
- ".gitignore"
|
49
63
|
- README.md
|
50
64
|
- lib/omniauth-swoop.rb
|
65
|
+
- lib/omniauth-swoop/version.rb
|
51
66
|
- lib/omniauth/strategies/swoop.rb
|
52
|
-
- lib/omniauth/swoop-version.rb
|
53
67
|
- omniauth-swoop.gemspec
|
54
68
|
homepage: https://github.com/swoop-password-free/omniauth-swoop
|
55
69
|
licenses: []
|