prx_auth-rails 1.8.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/prx_auth/rails/sessions_controller.rb +4 -1
- data/lib/prx_auth/rails/engine.rb +1 -0
- data/lib/prx_auth/rails/ext/controller.rb +52 -11
- data/lib/prx_auth/rails/version.rb +1 -1
- data/prx_auth-rails.gemspec +2 -0
- data/test/prx_auth/rails/ext/controller_test.rb +116 -0
- data/test/prx_auth/rails/sessions_controller_test.rb +3 -1
- data/test/test_helper.rb +1 -0
- metadata +34 -10
- data/app/assets/config/prx_auth-rails_manifest.js +0 -3
- data/app/assets/images/prx_auth-rails/user.svg +0 -5
- data/app/assets/javascripts/prx_auth-rails/user_widget.js.erb +0 -46
- data/app/assets/stylesheets/prx_auth-rails/user_widget.css +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be902ae2b7abfd4c01d28511d99931969fb3dce4aaff815fab35df005b99e07
|
4
|
+
data.tar.gz: dd3f5cf76251b17ceccaf307275401939e3d361ec01e215325674bff27aa5313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09589b75ff43d4da201e8ee6ebe7caca75dcada77e8c959588a7cc2832998d71eae72bea7bc44e8d0b02db5fa2dceb5284841930502bfbc8926096bb47cf9b63'
|
7
|
+
data.tar.gz: 1bf07c4a6edb477714297edbd2e6a1ba9e3289ef28babe973816eaf6b8984157b534b4556ec5840b5c6d4d7c7dc134fab415a404cc3bfbf2716b91c994f466c2
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PrxAuth::Rails
|
2
4
|
class SessionsController < ApplicationController
|
3
5
|
include PrxAuth::Rails::Engine.routes.url_helpers
|
@@ -5,8 +7,9 @@ module PrxAuth::Rails
|
|
5
7
|
skip_before_action :authenticate!
|
6
8
|
|
7
9
|
before_action :set_nonce!, only: [:new, :show]
|
10
|
+
before_action :set_after_sign_in_path
|
8
11
|
|
9
|
-
ID_NONCE_SESSION_KEY = 'id_prx_openid_nonce'
|
12
|
+
ID_NONCE_SESSION_KEY = 'id_prx_openid_nonce'
|
10
13
|
|
11
14
|
def new
|
12
15
|
config = PrxAuth::Rails.configuration
|
@@ -8,16 +8,25 @@ module PrxAuth
|
|
8
8
|
|
9
9
|
PRX_AUTH_ENV_KEY = 'prx.auth'.freeze
|
10
10
|
PRX_JWT_SESSION_KEY = 'prx.auth.jwt'.freeze
|
11
|
+
# subtracted from the JWT ttl
|
11
12
|
PRX_JWT_REFRESH_TTL = 300.freeze
|
12
13
|
PRX_ACCOUNT_MAPPING_SESSION_KEY = 'prx.auth.account.mapping'.freeze
|
14
|
+
PRX_USER_INFO_SESSION_KEY = 'prx.auth.info'.freeze
|
13
15
|
PRX_REFRESH_BACK_KEY = 'prx.auth.back'.freeze
|
14
16
|
|
15
17
|
def prx_auth_token
|
16
18
|
env_token || session_token
|
17
19
|
rescue SessionTokenExpiredError
|
18
|
-
|
20
|
+
session.delete(PRX_JWT_SESSION_KEY)
|
21
|
+
session.delete(PRX_ACCOUNT_MAPPING_SESSION_KEY)
|
22
|
+
session.delete(PRX_USER_INFO_SESSION_KEY)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_after_sign_in_path
|
27
|
+
return if self.class == PrxAuth::Rails::SessionsController
|
28
|
+
|
19
29
|
session[PRX_REFRESH_BACK_KEY] = request.fullpath
|
20
|
-
redirect_to PrxAuth::Rails::Engine.routes.url_helpers.new_sessions_path
|
21
30
|
end
|
22
31
|
|
23
32
|
def prx_jwt
|
@@ -34,17 +43,43 @@ module PrxAuth
|
|
34
43
|
redirect_to PrxAuth::Rails::Engine.routes.url_helpers.new_sessions_path
|
35
44
|
end
|
36
45
|
|
46
|
+
def prx_auth_needs_refresh?(jwt_ttl)
|
47
|
+
request.get? && jwt_ttl < PRX_JWT_REFRESH_TTL
|
48
|
+
end
|
49
|
+
|
37
50
|
def current_user
|
38
51
|
prx_auth_token
|
39
52
|
end
|
40
53
|
|
54
|
+
def current_user_info
|
55
|
+
session[PRX_USER_INFO_SESSION_KEY] ||= fetch_userinfo
|
56
|
+
end
|
57
|
+
|
58
|
+
def current_user_name
|
59
|
+
current_user_info['name'] || current_user_info['preferred_username'] || current_user_info['email']
|
60
|
+
end
|
61
|
+
|
62
|
+
def current_user_apps
|
63
|
+
apps = (current_user_info.try(:[], 'apps') || []).map do |name, url|
|
64
|
+
label = name.sub(/^https?:\/\//, '').sub(/\..+/, '').capitalize
|
65
|
+
["PRX #{label}", url]
|
66
|
+
end
|
67
|
+
|
68
|
+
# only return entire list in development
|
69
|
+
if ::Rails.env.production? || ::Rails.env.staging?
|
70
|
+
apps.to_h.select { |k, v| v.match?(/\.(org|tech)/) }
|
71
|
+
else
|
72
|
+
apps.to_h
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
41
76
|
def sign_in_user(token)
|
42
77
|
session[PRX_JWT_SESSION_KEY] = token
|
43
78
|
accounts_for(current_user.resources)
|
44
79
|
end
|
45
80
|
|
46
81
|
def after_sign_in_user_redirect
|
47
|
-
session
|
82
|
+
session[PRX_REFRESH_BACK_KEY]
|
48
83
|
end
|
49
84
|
|
50
85
|
def sign_out_user
|
@@ -52,7 +87,7 @@ module PrxAuth
|
|
52
87
|
end
|
53
88
|
|
54
89
|
def account_name_for(account_id)
|
55
|
-
account_for(account_id)[:name
|
90
|
+
account_for(account_id).try(:[], :name)
|
56
91
|
end
|
57
92
|
|
58
93
|
def account_for(account_id)
|
@@ -80,15 +115,21 @@ module PrxAuth
|
|
80
115
|
end
|
81
116
|
|
82
117
|
def fetch_accounts(ids)
|
83
|
-
id_host = PrxAuth::Rails.configuration.id_host
|
84
118
|
ids_param = ids.map(&:to_s).join(',')
|
119
|
+
resp = fetch("/api/v1/accounts?account_ids=#{ids_param}")
|
120
|
+
resp.try(:[], '_embedded').try(:[], 'prx:items') || []
|
121
|
+
end
|
122
|
+
|
123
|
+
def fetch_userinfo
|
124
|
+
fetch("/userinfo?scope=apps+email+profile", prx_jwt)
|
125
|
+
end
|
85
126
|
|
127
|
+
def fetch(path, token = nil)
|
128
|
+
url = "https://#{PrxAuth::Rails.configuration.id_host}#{path}"
|
86
129
|
options = {}
|
87
130
|
options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE if ::Rails.env.development?
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
JSON.parse(accounts)['accounts']
|
131
|
+
options['Authorization'] = "Bearer #{token}" if token
|
132
|
+
JSON.parse(URI.open(url, options).read)
|
92
133
|
end
|
93
134
|
|
94
135
|
# token from data set by prx_auth rack middleware
|
@@ -105,8 +146,8 @@ module PrxAuth
|
|
105
146
|
# NOTE: we already validated this jwt - so just decode it
|
106
147
|
validator = Rack::PrxAuth::AuthValidator.new(prx_jwt)
|
107
148
|
|
108
|
-
#
|
109
|
-
if
|
149
|
+
# does this jwt need to be refreshed?
|
150
|
+
if prx_auth_needs_refresh?(validator.time_to_live)
|
110
151
|
raise SessionTokenExpiredError.new
|
111
152
|
end
|
112
153
|
|
data/prx_auth-rails.gemspec
CHANGED
@@ -27,9 +27,11 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'coveralls', '~> 0'
|
28
28
|
spec.add_development_dependency 'guard'
|
29
29
|
spec.add_development_dependency 'guard-minitest'
|
30
|
+
spec.add_development_dependency 'm', '~> 1.5'
|
30
31
|
spec.add_development_dependency "rails", "~> 6.1.0"
|
31
32
|
spec.add_development_dependency 'pry'
|
32
33
|
spec.add_development_dependency 'sqlite3'
|
34
|
+
spec.add_development_dependency 'webmock'
|
33
35
|
|
34
36
|
spec.add_runtime_dependency 'prx_auth', ">= 1.7.0"
|
35
37
|
end
|
@@ -6,9 +6,21 @@ module PrxAuth::Rails::Ext
|
|
6
6
|
setup do
|
7
7
|
@controller = ApplicationController.new
|
8
8
|
@jwt_session_key = ApplicationController::PRX_JWT_SESSION_KEY
|
9
|
+
@user_info_key = ApplicationController::PRX_USER_INFO_SESSION_KEY
|
10
|
+
@account_mapping_key = ApplicationController::PRX_ACCOUNT_MAPPING_SESSION_KEY
|
9
11
|
@stub_claims = {'iat' => Time.now.to_i, 'exp' => Time.now.to_i + 3600}
|
10
12
|
end
|
11
13
|
|
14
|
+
# stub auth and init controller+session by getting a page
|
15
|
+
def with_stubbed_auth(jwt)
|
16
|
+
session[@jwt_session_key] = 'some-jwt'
|
17
|
+
@controller.stub(:prx_auth_needs_refresh?, false) do
|
18
|
+
get :index
|
19
|
+
assert_equal response.code, '200'
|
20
|
+
yield
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
test 'redirects unless you are authenticated' do
|
13
25
|
get :index
|
14
26
|
assert_equal response.code, '302'
|
@@ -45,5 +57,109 @@ module PrxAuth::Rails::Ext
|
|
45
57
|
end
|
46
58
|
end
|
47
59
|
|
60
|
+
test 'fetches current user info' do
|
61
|
+
with_stubbed_auth('some-jwt') do
|
62
|
+
body = {
|
63
|
+
'name' => 'Some Username',
|
64
|
+
'apps' => {'publish.prx.test' => 'https://publish.prx.test'},
|
65
|
+
'other' => 'stuff'
|
66
|
+
}
|
67
|
+
|
68
|
+
id_host = PrxAuth::Rails.configuration.id_host
|
69
|
+
stub_request(:get, "https://#{id_host}/userinfo?scope=apps%20email%20profile").
|
70
|
+
with(headers: {'Authorization' => 'Bearer some-jwt'}).
|
71
|
+
to_return(status: 200, body: JSON.generate(body))
|
72
|
+
|
73
|
+
assert session[@user_info_key] == nil
|
74
|
+
assert_equal @controller.current_user_info, body
|
75
|
+
refute session[@user_info_key] == nil
|
76
|
+
assert_equal @controller.current_user_name, 'Some Username'
|
77
|
+
assert_equal @controller.current_user_apps, {'PRX Publish' => 'https://publish.prx.test'}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'has user name fallbacks' do
|
82
|
+
with_stubbed_auth('some-jwt') do
|
83
|
+
session[@user_info_key] = {'name' => 'one', 'preferred_username' => 'two', 'email' => 'three'}
|
84
|
+
assert_equal @controller.current_user_name, 'one'
|
85
|
+
|
86
|
+
session[@user_info_key] = {'preferred_username' => 'two', 'email' => 'three'}
|
87
|
+
assert_equal @controller.current_user_name, 'two'
|
88
|
+
|
89
|
+
session[@user_info_key] = {'email' => 'three'}
|
90
|
+
assert_equal @controller.current_user_name, 'three'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
test 'filters apps displayed in production' do
|
95
|
+
with_stubbed_auth('some-jwt') do
|
96
|
+
Rails.env.stub(:production?, true) do
|
97
|
+
session[@user_info_key] = {
|
98
|
+
'apps' => {
|
99
|
+
'localhost stuff' => 'http://localhost:4000/path1',
|
100
|
+
'publish.prx.test' => 'https://publish.prx.test/path2',
|
101
|
+
'metrics.prx.tech' => 'https://metrics.prx.tech/path3',
|
102
|
+
'augury.prx.org' => 'https://augury.prx.org/path4',
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
assert_equal @controller.current_user_apps, {
|
107
|
+
'PRX Metrics' => 'https://metrics.prx.tech/path3',
|
108
|
+
'PRX Augury' => 'https://augury.prx.org/path4',
|
109
|
+
}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
test 'fetches accounts' do
|
115
|
+
with_stubbed_auth('some-jwt') do
|
116
|
+
one = {'id' => 1, 'type' => 'IndividualAccount', 'name' => 'One'}
|
117
|
+
three = {'id' => 3, 'type' => 'GroupAccount', 'name' => 'Three'}
|
118
|
+
body = {'_embedded' => {'prx:items' => [one, three]}}
|
119
|
+
|
120
|
+
id_host = PrxAuth::Rails.configuration.id_host
|
121
|
+
stub_request(:get, "https://#{id_host}/api/v1/accounts?account_ids=1,2,3").
|
122
|
+
to_return(status: 200, body: JSON.generate(body))
|
123
|
+
|
124
|
+
assert_nil session[@account_mapping_key]
|
125
|
+
assert_equal @controller.accounts_for([1, 2, 3]), [one, nil, three]
|
126
|
+
refute_nil session[@account_mapping_key]
|
127
|
+
assert_equal @controller.account_for(1), one
|
128
|
+
assert_equal @controller.account_for(3), three
|
129
|
+
assert_equal @controller.account_name_for(1), 'One'
|
130
|
+
assert_equal @controller.account_name_for(3), 'Three'
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
test 'handles unknown account ids' do
|
135
|
+
with_stubbed_auth('some-jwt') do
|
136
|
+
id_host = PrxAuth::Rails.configuration.id_host
|
137
|
+
stub_request(:get, "https://#{id_host}/api/v1/accounts?account_ids=2").
|
138
|
+
to_return(status: 200, body: JSON.generate({'_embedded' => {'prx:items' => []}})).
|
139
|
+
times(3)
|
140
|
+
|
141
|
+
assert_equal @controller.accounts_for([2]), [nil]
|
142
|
+
assert_nil @controller.account_for(2)
|
143
|
+
assert_nil @controller.account_name_for(2)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
test 'only fetches only missing accounts' do
|
148
|
+
with_stubbed_auth('some-jwt') do
|
149
|
+
one = {'name' => 'One'}
|
150
|
+
two = {'id' => 2, 'type' => 'StationAccount', 'name' => 'Two'}
|
151
|
+
three = {'name' => 'Three'}
|
152
|
+
session[@account_mapping_key] = {1 => one, 3 => three}
|
153
|
+
body = {'_embedded' => {'prx:items' => [two]}}
|
154
|
+
|
155
|
+
id_host = PrxAuth::Rails.configuration.id_host
|
156
|
+
stub_request(:get, "https://#{id_host}/api/v1/accounts?account_ids=2").
|
157
|
+
to_return(status: 200, body: JSON.generate(body))
|
158
|
+
|
159
|
+
assert_equal @controller.accounts_for([1, 2, 3]), [one, two, three]
|
160
|
+
assert_equal @controller.account_for(2), two
|
161
|
+
assert_equal @controller.account_name_for(2), 'Two'
|
162
|
+
end
|
163
|
+
end
|
48
164
|
end
|
49
165
|
end
|
@@ -71,7 +71,9 @@ module PrxAuth::Rails
|
|
71
71
|
session[@refresh_back_key] = '/lets/go/here?okay'
|
72
72
|
post :create, params: @token_params, format: :json
|
73
73
|
|
74
|
-
|
74
|
+
# A trailing log of the 'last' page
|
75
|
+
assert session[@refresh_back_key] == '/lets/go/here?okay'
|
76
|
+
|
75
77
|
assert response.code == '302'
|
76
78
|
assert response.headers['Location'].ends_with?('/lets/go/here?okay')
|
77
79
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prx_auth-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Rhoden
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: m
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.5'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,20 @@ dependencies:
|
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: prx_auth
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,10 +191,6 @@ files:
|
|
163
191
|
- LICENSE.txt
|
164
192
|
- README.md
|
165
193
|
- Rakefile
|
166
|
-
- app/assets/config/prx_auth-rails_manifest.js
|
167
|
-
- app/assets/images/prx_auth-rails/user.svg
|
168
|
-
- app/assets/javascripts/prx_auth-rails/user_widget.js.erb
|
169
|
-
- app/assets/stylesheets/prx_auth-rails/user_widget.css
|
170
194
|
- app/controllers/prx_auth/rails/sessions_controller.rb
|
171
195
|
- app/views/prx_auth/rails/sessions/auth_error.html.erb
|
172
196
|
- app/views/prx_auth/rails/sessions/show.html.erb
|
@@ -246,7 +270,7 @@ homepage: https://github.com/PRX/prx_auth-rails
|
|
246
270
|
licenses:
|
247
271
|
- MIT
|
248
272
|
metadata: {}
|
249
|
-
post_install_message:
|
273
|
+
post_install_message:
|
250
274
|
rdoc_options: []
|
251
275
|
require_paths:
|
252
276
|
- lib
|
@@ -261,8 +285,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
285
|
- !ruby/object:Gem::Version
|
262
286
|
version: '0'
|
263
287
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
265
|
-
signing_key:
|
288
|
+
rubygems_version: 3.3.3
|
289
|
+
signing_key:
|
266
290
|
specification_version: 4
|
267
291
|
summary: Rails integration for next generation PRX Authorization system.
|
268
292
|
test_files:
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3
|
-
<svg width="100%" height="100%" viewBox="0 0 51 51" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
|
4
|
-
<path d="M51,25.5C51,11.44 39.56,0 25.5,0C11.44,0 0,11.44 0,25.5C0,32.927 3.194,39.621 8.277,44.285L8.253,44.306L9.08,45.003C9.134,45.049 9.192,45.086 9.246,45.13C9.685,45.495 10.141,45.841 10.604,46.175C10.755,46.284 10.905,46.392 11.058,46.498C11.553,46.839 12.061,47.163 12.58,47.47C12.693,47.537 12.807,47.602 12.922,47.666C13.49,47.99 14.07,48.295 14.665,48.575C14.708,48.596 14.753,48.614 14.796,48.635C16.734,49.535 18.801,50.196 20.964,50.586C21.02,50.597 21.077,50.607 21.134,50.617C21.806,50.733 22.485,50.826 23.172,50.888C23.255,50.895 23.339,50.9 23.423,50.907C24.107,50.964 24.799,51 25.5,51C26.195,51 26.88,50.964 27.56,50.909C27.647,50.902 27.733,50.897 27.819,50.89C28.501,50.828 29.174,50.738 29.839,50.624C29.896,50.613 29.955,50.603 30.012,50.592C32.142,50.21 34.18,49.564 36.092,48.686C36.163,48.654 36.234,48.623 36.305,48.59C36.877,48.321 37.436,48.031 37.984,47.722C38.12,47.645 38.256,47.567 38.391,47.487C38.89,47.194 39.38,46.887 39.857,46.56C40.029,46.443 40.196,46.32 40.366,46.198C40.773,45.905 41.173,45.602 41.561,45.286C41.648,45.217 41.74,45.156 41.825,45.085L42.673,44.376L42.648,44.355C47.776,39.689 51,32.965 51,25.5ZM1.855,25.5C1.855,12.462 12.462,1.855 25.5,1.855C38.538,1.855 49.145,12.462 49.145,25.5C49.145,32.526 46.062,38.843 41.181,43.177C40.908,42.988 40.634,42.82 40.353,42.679L32.502,38.754C31.797,38.401 31.359,37.693 31.359,36.905L31.359,34.164C31.541,33.939 31.733,33.685 31.932,33.406C32.948,31.971 33.763,30.374 34.357,28.656C35.532,28.097 36.291,26.927 36.291,25.606L36.291,22.319C36.291,21.515 35.996,20.735 35.468,20.122L35.468,15.794C35.516,15.312 35.687,12.597 33.722,10.357C32.013,8.406 29.247,7.418 25.5,7.418C21.753,7.418 18.987,8.406 17.278,10.356C15.313,12.596 15.484,15.313 15.532,15.793L15.532,20.121C15.005,20.734 14.709,21.514 14.709,22.318L14.709,25.605C14.709,26.626 15.167,27.578 15.952,28.221C16.703,31.163 18.249,33.39 18.82,34.145L18.82,36.828C18.82,37.585 18.407,38.281 17.742,38.644L10.41,42.643C10.177,42.77 9.945,42.919 9.713,43.085C4.892,38.753 1.855,32.475 1.855,25.5Z" style="fill:white;fill-rule:nonzero;"/>
|
5
|
-
</svg>
|
@@ -1,46 +0,0 @@
|
|
1
|
-
// https://stackoverflow.com/questions/8578617/inject-a-script-tag-with-remote-src-and-wait-for-it-to-execute
|
2
|
-
function prxInjectScript(src, callback) {
|
3
|
-
const script = document.createElement('script');
|
4
|
-
|
5
|
-
script.type = 'text/javascript';
|
6
|
-
script.async = false;
|
7
|
-
script.src = src;
|
8
|
-
|
9
|
-
script.onload = function () { script.onload = null; callback(); }
|
10
|
-
|
11
|
-
document.getElementsByTagName('head')[0].appendChild(script);
|
12
|
-
}
|
13
|
-
|
14
|
-
document.addEventListener('DOMContentLoaded', function () {
|
15
|
-
|
16
|
-
const widget = document.getElementById('prx-user-widget');
|
17
|
-
const account = document.getElementById('prx-user-widget-menu-account');
|
18
|
-
|
19
|
-
const idHost = 'https://' + widget.getAttribute('data-id-host');;
|
20
|
-
const scriptUrl = idHost + '/widget.js';
|
21
|
-
|
22
|
-
prxInjectScript(scriptUrl, function () {
|
23
|
-
const signIn = new PRXSignIn(idHost);
|
24
|
-
|
25
|
-
signIn.signedIn(function (prx) {
|
26
|
-
|
27
|
-
if (!prx.userinfo) {
|
28
|
-
// Not logged in
|
29
|
-
widget.classList.add('no-user-info');
|
30
|
-
|
31
|
-
const url = idHost + '/session?return_to=' + encodeURIComponent(window.location);
|
32
|
-
|
33
|
-
account.innerHTML = '<a class=sign-in href="' + url + '">Sign in</a>';
|
34
|
-
} else {
|
35
|
-
// Logged in
|
36
|
-
widget.classList.add('user-info');
|
37
|
-
|
38
|
-
const account = document.getElementById('prx-user-widget-menu-account');
|
39
|
-
account.innerText = prx.userinfo.email;
|
40
|
-
|
41
|
-
signIn.listApps('prx-user-widget-menu-apps');
|
42
|
-
}
|
43
|
-
});
|
44
|
-
});
|
45
|
-
});
|
46
|
-
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#prx-user-widget {
|
2
|
-
display: flex;
|
3
|
-
flex-direction: column;
|
4
|
-
height: 100%;
|
5
|
-
justify-content: center;
|
6
|
-
padding: 0 20px;
|
7
|
-
position: absolute;
|
8
|
-
right: 0;
|
9
|
-
transition-property: opacity;
|
10
|
-
transition-duration: 0.2s;
|
11
|
-
}
|
12
|
-
@media (max-width: ) {
|
13
|
-
#prx-user-widget {
|
14
|
-
height: auto;
|
15
|
-
top: 0;
|
16
|
-
}
|
17
|
-
}
|
18
|
-
#prx-user-widget:hover {
|
19
|
-
}
|
20
|
-
#prx-user-widget:hover .user-icon {
|
21
|
-
opacity: 1;
|
22
|
-
}
|
23
|
-
#prx-user-widget:hover #prx-user-widget-menu {
|
24
|
-
display: block;
|
25
|
-
}
|
26
|
-
#prx-user-widget .user-icon {
|
27
|
-
cursor: pointer;
|
28
|
-
height: 2em;
|
29
|
-
opacity: 0.7;
|
30
|
-
width: 2em;
|
31
|
-
}
|
32
|
-
#prx-user-widget #prx-user-widget-menu {
|
33
|
-
background-color: #1a1a1a;
|
34
|
-
display: none;
|
35
|
-
right: 0;
|
36
|
-
padding: 10px 20px;
|
37
|
-
position: absolute;
|
38
|
-
top: 100%;
|
39
|
-
z-index: 999;
|
40
|
-
display: none;
|
41
|
-
}
|
42
|
-
|
43
|
-
#prx-user-widget #prx-user-widget-menu h1 {
|
44
|
-
color: white;
|
45
|
-
font-size: .9em;
|
46
|
-
font-weight: 700;
|
47
|
-
}
|
48
|
-
|
49
|
-
#prx-user-widget #prx-user-widget-menu-apps {
|
50
|
-
padding: 0;
|
51
|
-
}
|
52
|
-
#prx-user-widget #prx-user-widget-menu-apps ul {
|
53
|
-
border-top: 1px solid #ddd;
|
54
|
-
padding: 15px 0 0;
|
55
|
-
}
|
56
|
-
|
57
|
-
#prx-user-widget #prx-user-widget-menu-apps ul li a {
|
58
|
-
display: block;
|
59
|
-
font-weight: normal;
|
60
|
-
opacity: 0.7;
|
61
|
-
padding: 5px 0;
|
62
|
-
text-transform: none;
|
63
|
-
}
|
64
|
-
#prx-user-widget #prx-user-widget-menu-apps ul li a:hover {
|
65
|
-
opacity: 1;
|
66
|
-
}
|
67
|
-
.prx-home #prx-user-widget.loaded:hover {
|
68
|
-
background: transparent;
|
69
|
-
}
|