omniauth-cronofy 0.8.0 → 0.9.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e0e7501a9711c3f3d141dda702bfbf5c37ee617
|
4
|
+
data.tar.gz: 92784956009981fc95d5f9b3e45eaf13ebab8932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 943321f4df579cd5a26c705a9c954d0380c0936ec1d938391763076c9aad57eda56e4e2beaf59ffbc33971b44a5b723c2118618705e3645d38584ce798f5aac3
|
7
|
+
data.tar.gz: 488e4b202f99f511e9a911a9ecba76470642bbb92faa12deff3cd4e1e5fcc8b1f8d8b620d2269227b116cb4753d054551bfeb8452926e3ad9b5adbcef117ed50
|
data/lib/omniauth-cronofy.rb
CHANGED
@@ -1,43 +1,9 @@
|
|
1
1
|
module OmniAuth
|
2
2
|
module Strategies
|
3
|
-
class Cronofy <
|
3
|
+
class Cronofy < CronofyBase
|
4
4
|
option :name, "cronofy"
|
5
5
|
|
6
|
-
|
7
|
-
@api_url ||= (ENV['CRONOFY_API_URL'] || data_centre_api_url || "https://api.cronofy.com")
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.data_centre_api_url
|
11
|
-
case ENV['CRONOFY_DATA_CENTRE']
|
12
|
-
when 'de'
|
13
|
-
"https://api-#{ENV['CRONOFY_DATA_CENTRE']}.cronofy.com"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.api_url=(value)
|
18
|
-
@api_url = value
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.app_url
|
22
|
-
@app_url ||= (ENV['CRONOFY_APP_URL'] || data_centre_app_url || "https://app.cronofy.com")
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.data_centre_app_url
|
26
|
-
case ENV['CRONOFY_DATA_CENTRE']
|
27
|
-
when 'de'
|
28
|
-
"https://app-#{ENV['CRONOFY_DATA_CENTRE']}.cronofy.com"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.app_url=(value)
|
33
|
-
@app_url = value
|
34
|
-
end
|
35
|
-
|
36
|
-
option :client_options, {
|
37
|
-
:site => ::OmniAuth::Strategies::Cronofy.app_url
|
38
|
-
}
|
39
|
-
|
40
|
-
uid{ raw_info['account_id'] }
|
6
|
+
uid { raw_info['account_id'] }
|
41
7
|
|
42
8
|
info do
|
43
9
|
{
|
@@ -58,7 +24,7 @@ module OmniAuth
|
|
58
24
|
end
|
59
25
|
|
60
26
|
def raw_info
|
61
|
-
@raw_info ||= access_token.get("#{
|
27
|
+
@raw_info ||= access_token.get("#{client_options[:api_url]}/v1/account").parsed['account']
|
62
28
|
end
|
63
29
|
end
|
64
30
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
class CronofyBase < OmniAuth::Strategies::OAuth2
|
4
|
+
option :data_center, nil
|
5
|
+
|
6
|
+
def api_url
|
7
|
+
ENV['CRONOFY_API_URL'] || data_center_url(:api, data_center_env) || "https://api.cronofy.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
def app_url
|
11
|
+
ENV['CRONOFY_APP_URL'] || data_center_url(:app, data_center_env) || "https://app.cronofy.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
def data_center_env
|
15
|
+
ENV['CRONOFY_DATA_CENTER'] || ENV['CRONOFY_DATA_CENTRE']
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_center_url(type, value)
|
19
|
+
case value.to_s
|
20
|
+
when 'de'
|
21
|
+
"https://#{type}-#{value}.cronofy.com"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def client_options
|
26
|
+
client_options = deep_symbolize(options.client_options)
|
27
|
+
|
28
|
+
unless client_options[:site]
|
29
|
+
if options.data_center
|
30
|
+
client_options[:site] = data_center_url(:app, options.data_center)
|
31
|
+
end
|
32
|
+
|
33
|
+
unless client_options[:site]
|
34
|
+
client_options[:site] = app_url
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
unless client_options[:api_url]
|
39
|
+
if options.data_center
|
40
|
+
client_options[:api_url] = data_center_url(:api, options.data_center)
|
41
|
+
end
|
42
|
+
|
43
|
+
unless client_options[:api_url]
|
44
|
+
client_options[:api_url] = api_url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
log :debug, "site: #{client_options[:site]}, api_url: #{client_options[:api_url]}"
|
49
|
+
|
50
|
+
client_options
|
51
|
+
end
|
52
|
+
|
53
|
+
def client
|
54
|
+
::OAuth2::Client.new(options.client_id, options.client_secret, client_options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module OmniAuth
|
2
2
|
module Strategies
|
3
|
-
class CronofyServiceAccount <
|
3
|
+
class CronofyServiceAccount < CronofyBase
|
4
4
|
option :name, "cronofy_service_account"
|
5
5
|
|
6
6
|
option :client_options, {
|
7
|
-
:
|
8
|
-
:authorize_url => "#{::OmniAuth::Strategies::Cronofy.app_url}/enterprise_connect/oauth/authorize",
|
7
|
+
:authorize_url => "/enterprise_connect/oauth/authorize",
|
9
8
|
}
|
10
9
|
|
11
10
|
def request_phase
|
@@ -13,7 +12,7 @@ module OmniAuth
|
|
13
12
|
super
|
14
13
|
end
|
15
14
|
|
16
|
-
uid{ raw_info['sub'] }
|
15
|
+
uid { raw_info['sub'] }
|
17
16
|
|
18
17
|
info do
|
19
18
|
{
|
@@ -32,7 +31,7 @@ module OmniAuth
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def raw_info
|
35
|
-
@raw_info ||= access_token.get("#{
|
34
|
+
@raw_info ||= access_token.get("#{client_options[:api_url]}/v1/userinfo").parsed
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/omniauth-cronofy/version.rb
|
89
89
|
- lib/omniauth/.DS_Store
|
90
90
|
- lib/omniauth/strategies/cronofy.rb
|
91
|
+
- lib/omniauth/strategies/cronofy_base.rb
|
91
92
|
- lib/omniauth/strategies/cronofy_service_account.rb
|
92
93
|
- omniauth-cronofy.gemspec
|
93
94
|
homepage: https://github.com/cronofy/omniauth-cronofy
|