strongmind-platform-sdk 2.12.1 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -3
- data/Gemfile.lock +151 -17
- data/Makefile +4 -1
- data/docs/identity_installation_in_rails.md +30 -0
- data/lib/generators/strong_mind_rails_identity/install_generator.rb +74 -0
- data/lib/generators/templates/add_uid_to_user.rb +8 -0
- data/lib/generators/templates/devise.rb +328 -0
- data/lib/generators/templates/omniauth_callbacks_controller.rb +16 -0
- data/lib/generators/templates/strong_mind_auto_login.html.erb +9 -0
- data/lib/generators/templates/strong_mind_auto_login.signed_in.html.erb +3 -0
- data/lib/generators/templates/strong_mind_auto_login_controller.rb +5 -0
- data/lib/platform_sdk/version.rb +1 -1
- metadata +69 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b164de74220b62fc27130b03a337a2d75c32519a954dc5e7e56ccd39ffa2e71f
|
4
|
+
data.tar.gz: 3e9813743a652d09e5f00a7a256542db88080580741a80c7ce81b8a7b91aaced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c3c8a45908a4cb204235c81511bfaa632e635e3e0e07f263dcab13c04d32f9648e2d56ec65b92c69edbbe485f376e1925663666299a028ef43969f768f6711
|
7
|
+
data.tar.gz: 8047cfca6928a4628c1f47c21a46c191895b7ce707a2d3027b9fd729bc992cf5ea262b7b40946baac6354b5a3eb91ac4a85527b878c6238fe33150edb2bb811e
|
data/Gemfile
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
end
|
5
|
+
gem "strongmind-oneroster-client", "~> 2.0.3"
|
6
|
+
|
8
7
|
|
9
8
|
# Specify your gem's dependencies in platform_sdk-ruby-sdk.gemspec
|
10
9
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,58 +1,178 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
platform-sdk (2.
|
4
|
+
strongmind-platform-sdk (2.13.0)
|
5
5
|
aws-sdk-secretsmanager (~> 1.66)
|
6
|
+
devise
|
6
7
|
faraday (~> 2.5, >= 2.5.2)
|
7
|
-
|
8
|
+
omniauth
|
9
|
+
omniauth-rails_csrf_protection
|
10
|
+
omniauth_openid_connect
|
11
|
+
strongmind-oneroster-client (~> 2.0.1)
|
8
12
|
uri
|
9
13
|
|
10
14
|
GEM
|
11
15
|
remote: https://rubygems.org/
|
12
16
|
specs:
|
17
|
+
actionpack (7.0.4)
|
18
|
+
actionview (= 7.0.4)
|
19
|
+
activesupport (= 7.0.4)
|
20
|
+
rack (~> 2.0, >= 2.2.0)
|
21
|
+
rack-test (>= 0.6.3)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
24
|
+
actionview (7.0.4)
|
25
|
+
activesupport (= 7.0.4)
|
26
|
+
builder (~> 3.1)
|
27
|
+
erubi (~> 1.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
30
|
+
activemodel (7.0.4)
|
31
|
+
activesupport (= 7.0.4)
|
13
32
|
activesupport (7.0.4)
|
14
33
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
34
|
i18n (>= 1.6, < 2)
|
16
35
|
minitest (>= 5.1)
|
17
36
|
tzinfo (~> 2.0)
|
37
|
+
aes_key_wrap (1.1.0)
|
18
38
|
ast (2.4.2)
|
39
|
+
attr_required (1.0.1)
|
19
40
|
aws-eventstream (1.2.0)
|
20
|
-
aws-partitions (1.
|
21
|
-
aws-sdk-core (3.
|
41
|
+
aws-partitions (1.745.0)
|
42
|
+
aws-sdk-core (3.171.0)
|
22
43
|
aws-eventstream (~> 1, >= 1.0.2)
|
23
44
|
aws-partitions (~> 1, >= 1.651.0)
|
24
45
|
aws-sigv4 (~> 1.5)
|
25
46
|
jmespath (~> 1, >= 1.6.1)
|
26
|
-
aws-sdk-secretsmanager (1.
|
47
|
+
aws-sdk-secretsmanager (1.73.0)
|
27
48
|
aws-sdk-core (~> 3, >= 3.165.0)
|
28
49
|
aws-sigv4 (~> 1.1)
|
29
50
|
aws-sigv4 (1.5.2)
|
30
51
|
aws-eventstream (~> 1, >= 1.0.2)
|
52
|
+
bcrypt (3.1.18)
|
53
|
+
bindata (2.4.15)
|
54
|
+
builder (3.2.4)
|
31
55
|
concurrent-ruby (1.1.10)
|
56
|
+
crass (1.0.6)
|
57
|
+
date (3.3.3)
|
58
|
+
devise (4.9.2)
|
59
|
+
bcrypt (~> 3.0)
|
60
|
+
orm_adapter (~> 0.1)
|
61
|
+
railties (>= 4.1.0)
|
62
|
+
responders
|
63
|
+
warden (~> 1.2.3)
|
32
64
|
diff-lcs (1.5.0)
|
33
|
-
|
65
|
+
erubi (1.12.0)
|
66
|
+
ethon (0.16.0)
|
34
67
|
ffi (>= 1.15.0)
|
35
68
|
factory_bot (6.2.1)
|
36
69
|
activesupport (>= 5.0.0)
|
37
70
|
faker (2.23.0)
|
38
71
|
i18n (>= 1.8.11, < 2)
|
39
|
-
faraday (2.7.
|
72
|
+
faraday (2.7.4)
|
40
73
|
faraday-net_http (>= 2.0, < 3.1)
|
41
74
|
ruby2_keywords (>= 0.0.4)
|
75
|
+
faraday-follow_redirects (0.3.0)
|
76
|
+
faraday (>= 1, < 3)
|
42
77
|
faraday-net_http (3.0.2)
|
43
78
|
ffi (1.15.5)
|
79
|
+
hashie (5.0.0)
|
80
|
+
httpclient (2.8.3)
|
44
81
|
i18n (1.12.0)
|
45
82
|
concurrent-ruby (~> 1.0)
|
46
83
|
jmespath (1.6.2)
|
47
84
|
json (2.6.2)
|
85
|
+
json-jwt (1.16.3)
|
86
|
+
activesupport (>= 4.2)
|
87
|
+
aes_key_wrap
|
88
|
+
bindata
|
89
|
+
faraday (~> 2.0)
|
90
|
+
faraday-follow_redirects
|
48
91
|
jwt (1.5.6)
|
92
|
+
loofah (2.20.0)
|
93
|
+
crass (~> 1.0.2)
|
94
|
+
nokogiri (>= 1.5.9)
|
95
|
+
mail (2.8.1)
|
96
|
+
mini_mime (>= 0.1.1)
|
97
|
+
net-imap
|
98
|
+
net-pop
|
99
|
+
net-smtp
|
100
|
+
method_source (1.0.0)
|
101
|
+
mini_mime (1.1.2)
|
102
|
+
mini_portile2 (2.8.1)
|
49
103
|
minitest (5.16.3)
|
104
|
+
net-imap (0.3.4)
|
105
|
+
date
|
106
|
+
net-protocol
|
107
|
+
net-pop (0.1.2)
|
108
|
+
net-protocol
|
109
|
+
net-protocol (0.2.1)
|
110
|
+
timeout
|
111
|
+
net-smtp (0.3.3)
|
112
|
+
net-protocol
|
113
|
+
nokogiri (1.14.3)
|
114
|
+
mini_portile2 (~> 2.8.0)
|
115
|
+
racc (~> 1.4)
|
116
|
+
nokogiri (1.14.3-x86_64-darwin)
|
117
|
+
racc (~> 1.4)
|
118
|
+
nokogiri (1.14.3-x86_64-linux)
|
119
|
+
racc (~> 1.4)
|
120
|
+
omniauth (2.1.1)
|
121
|
+
hashie (>= 3.4.6)
|
122
|
+
rack (>= 2.2.3)
|
123
|
+
rack-protection
|
124
|
+
omniauth-rails_csrf_protection (1.0.1)
|
125
|
+
actionpack (>= 4.2)
|
126
|
+
omniauth (~> 2.0)
|
127
|
+
omniauth_openid_connect (0.6.1)
|
128
|
+
omniauth (>= 1.9, < 3)
|
129
|
+
openid_connect (~> 1.1)
|
130
|
+
openid_connect (1.4.2)
|
131
|
+
activemodel
|
132
|
+
attr_required (>= 1.0.0)
|
133
|
+
json-jwt (>= 1.15.0)
|
134
|
+
net-smtp
|
135
|
+
rack-oauth2 (~> 1.21)
|
136
|
+
swd (~> 1.3)
|
137
|
+
tzinfo
|
138
|
+
validate_email
|
139
|
+
validate_url
|
140
|
+
webfinger (~> 1.2)
|
141
|
+
orm_adapter (0.5.0)
|
50
142
|
parallel (1.22.1)
|
51
143
|
parser (3.1.2.1)
|
52
144
|
ast (~> 2.4.1)
|
145
|
+
public_suffix (5.0.1)
|
146
|
+
racc (1.6.2)
|
147
|
+
rack (2.2.6.4)
|
148
|
+
rack-oauth2 (1.21.3)
|
149
|
+
activesupport
|
150
|
+
attr_required
|
151
|
+
httpclient
|
152
|
+
json-jwt (>= 1.11.0)
|
153
|
+
rack (>= 2.1.0)
|
154
|
+
rack-protection (3.0.6)
|
155
|
+
rack
|
156
|
+
rack-test (2.1.0)
|
157
|
+
rack (>= 1.3)
|
158
|
+
rails-dom-testing (2.0.3)
|
159
|
+
activesupport (>= 4.2.0)
|
160
|
+
nokogiri (>= 1.6)
|
161
|
+
rails-html-sanitizer (1.5.0)
|
162
|
+
loofah (~> 2.19, >= 2.19.1)
|
163
|
+
railties (7.0.4)
|
164
|
+
actionpack (= 7.0.4)
|
165
|
+
activesupport (= 7.0.4)
|
166
|
+
method_source
|
167
|
+
rake (>= 12.2)
|
168
|
+
thor (~> 1.0)
|
169
|
+
zeitwerk (~> 2.5)
|
53
170
|
rainbow (3.1.1)
|
54
171
|
rake (13.0.6)
|
55
172
|
regexp_parser (2.6.0)
|
173
|
+
responders (3.1.0)
|
174
|
+
actionpack (>= 5.2)
|
175
|
+
railties (>= 5.2)
|
56
176
|
rexml (3.2.5)
|
57
177
|
rspec (3.11.0)
|
58
178
|
rspec-core (~> 3.11.0)
|
@@ -81,19 +201,33 @@ GEM
|
|
81
201
|
parser (>= 3.1.1.0)
|
82
202
|
ruby-progressbar (1.11.0)
|
83
203
|
ruby2_keywords (0.0.5)
|
204
|
+
strongmind-oneroster-client (2.0.3)
|
205
|
+
json (~> 2.1, >= 2.1.0)
|
206
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
207
|
+
swd (1.3.0)
|
208
|
+
activesupport (>= 3)
|
209
|
+
attr_required (>= 0.0.5)
|
210
|
+
httpclient (>= 2.4)
|
211
|
+
thor (1.2.1)
|
212
|
+
timeout (0.3.2)
|
84
213
|
typhoeus (1.4.0)
|
85
214
|
ethon (>= 0.9.0)
|
86
215
|
tzinfo (2.0.5)
|
87
216
|
concurrent-ruby (~> 1.0)
|
88
217
|
unicode-display_width (2.3.0)
|
89
|
-
uri (0.12.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
218
|
+
uri (0.12.1)
|
219
|
+
validate_email (0.1.6)
|
220
|
+
activemodel (>= 3.0)
|
221
|
+
mail (>= 2.2.5)
|
222
|
+
validate_url (1.0.15)
|
223
|
+
activemodel (>= 3.0.0)
|
224
|
+
public_suffix
|
225
|
+
warden (1.2.9)
|
226
|
+
rack (>= 2.0.9)
|
227
|
+
webfinger (1.2.0)
|
228
|
+
activesupport
|
229
|
+
httpclient (>= 2.4)
|
230
|
+
zeitwerk (2.6.7)
|
97
231
|
|
98
232
|
PLATFORMS
|
99
233
|
ruby
|
@@ -104,11 +238,11 @@ DEPENDENCIES
|
|
104
238
|
factory_bot
|
105
239
|
faker
|
106
240
|
jwt (~> 1.5, >= 1.5.4)
|
107
|
-
oneroster_client (~> 2.0.3)!
|
108
|
-
platform-sdk!
|
109
241
|
rake (~> 13.0)
|
110
242
|
rspec (~> 3.6, >= 3.6.0)
|
111
243
|
rubocop
|
244
|
+
strongmind-oneroster-client (~> 2.0.3)
|
245
|
+
strongmind-platform-sdk!
|
112
246
|
|
113
247
|
BUNDLED WITH
|
114
248
|
2.3.16
|
data/Makefile
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Add StrongMind Identity to a Rails app
|
2
|
+
1. Create a fresh rails app. ex: rails new my-app --css tailwind
|
3
|
+
1. Add this to Gemfile:
|
4
|
+
```ruby
|
5
|
+
gem "strongmind-platform-sdk"
|
6
|
+
gem 'dotenv-rails', groups: [:development, :test] # for environment variables when running locally
|
7
|
+
gem 'devise'
|
8
|
+
gem 'omniauth_openid_connect'
|
9
|
+
gem 'omniauth-rails_csrf_protection'
|
10
|
+
```
|
11
|
+
1. Run `bundle install`
|
12
|
+
|
13
|
+
1. Run the generator: `rails g strong_mind_rails_identity:install`
|
14
|
+
|
15
|
+
1. Execute `bin/rails db:migrate RAILS_ENV=development`
|
16
|
+
|
17
|
+
1. Create a client in the Identity Server and add the following to the .env file:
|
18
|
+
```
|
19
|
+
IDENTITY_CLIENT_ID=
|
20
|
+
IDENTITY_CLIENT_SECRET=
|
21
|
+
```
|
22
|
+
|
23
|
+
1. If you want user sessions to persist across restarts of your server in dev, and you aren't using redis in dev, add `config.cache_store = :file_store` to `config/environments/development.rb`
|
24
|
+
|
25
|
+
1. Remove the first devise line with the default devise plugins from `app/models/user.rb`. You should end up with the only devise line being
|
26
|
+
```ruby
|
27
|
+
devise :omniauthable, omniauth_providers: [:strongmind]
|
28
|
+
```
|
29
|
+
|
30
|
+
1. Start the server: `rails s`
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module StrongMindRailsIdentity
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path("../templates", __dir__)
|
9
|
+
|
10
|
+
def copy_initializer
|
11
|
+
template "devise.rb", "config/initializers/devise.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_omniauth_callbacks_controller
|
15
|
+
copy_file "omniauth_callbacks_controller.rb", "app/controllers/users/omniauth_callbacks_controller.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_auto_login
|
19
|
+
copy_file "strong_mind_auto_login_controller.rb", "app/controllers/strong_mind_auto_login_controller.rb"
|
20
|
+
copy_file "strong_mind_auto_login.html.erb", "app/views/strong_mind_auto_login/index.html.erb"
|
21
|
+
copy_file "strong_mind_auto_login.signed_in.html.erb", "app/views/strong_mind_auto_login/signed_in.html.erb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_devise_user
|
25
|
+
generate "active_record:devise User"
|
26
|
+
inject_into_file "app/models/user.rb", after: ":recoverable, :rememberable, :validatable\n" do
|
27
|
+
" devise :omniauthable, :omniauth_providers => %i[strongmind]
|
28
|
+
|
29
|
+
def self.from_omniauth(auth)
|
30
|
+
Rails.cache.write(auth.uid, auth)
|
31
|
+
email = auth.extra.raw_info['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress']
|
32
|
+
user = User.where(uid: auth.uid).first
|
33
|
+
if user.nil?
|
34
|
+
user ||= User.create!(uid: auth.uid, email: email)
|
35
|
+
end
|
36
|
+
user
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth
|
40
|
+
Rails.cache.read(uid)
|
41
|
+
end"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def add_devise_routes
|
48
|
+
devise_route = " devise_for :users, controllers: {
|
49
|
+
omniauth_callbacks: 'users/omniauth_callbacks'
|
50
|
+
}
|
51
|
+
devise_scope :user do
|
52
|
+
post 'users/sign_out', to: 'devise/sessions#destroy'
|
53
|
+
|
54
|
+
unauthenticated do
|
55
|
+
root 'strong_mind_auto_login#index', as: :unauthenticated_root
|
56
|
+
end
|
57
|
+
authenticated do
|
58
|
+
root 'strong_mind_auto_login#signed_in'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
".dup
|
62
|
+
route devise_route
|
63
|
+
end
|
64
|
+
|
65
|
+
def uid_migration
|
66
|
+
migration_template "add_uid_to_user.rb", "db/migrate/add_uid_to_user.rb"
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.next_migration_number(path)
|
70
|
+
# Add 1 to make sure this happens after the devise migration
|
71
|
+
(Time.now.utc.strftime("%Y%m%d%H%M%S").to_i + 1).to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,328 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Assuming you have not yet modified this file, each configuration option below
|
4
|
+
# is set to its default value. Note that some are commented out while others
|
5
|
+
# are not: uncommented lines are intended to protect your configuration from
|
6
|
+
# breaking changes in upgrades (i.e., in the event that future versions of
|
7
|
+
# Devise change the default values for those options).
|
8
|
+
#
|
9
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
10
|
+
# Many of these configuration options can be set straight in your model.
|
11
|
+
Devise.setup do |config|
|
12
|
+
# The secret key used by Devise. Devise uses this key to generate
|
13
|
+
# random tokens. Changing this key will render invalid all existing
|
14
|
+
# confirmation, reset password and unlock tokens in the database.
|
15
|
+
# Devise will use the `secret_key_base` as its `secret_key`
|
16
|
+
# by default. You can change it below and use your own secret key.
|
17
|
+
config.secret_key = ENV['DEVISE_SECRET_KEY'] || '<%= SecureRandom.hex(64) %>'
|
18
|
+
|
19
|
+
# ==> Controller configuration
|
20
|
+
# Configure the parent class to the devise controllers.
|
21
|
+
# config.parent_controller = 'DeviseController'
|
22
|
+
|
23
|
+
# ==> Mailer Configuration
|
24
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
25
|
+
# note that it will be overwritten if you use your own mailer class
|
26
|
+
# with default "from" parameter.
|
27
|
+
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
28
|
+
|
29
|
+
# Configure the class responsible to send e-mails.
|
30
|
+
# config.mailer = 'Devise::Mailer'
|
31
|
+
|
32
|
+
# Configure the parent class responsible to send e-mails.
|
33
|
+
# config.parent_mailer = 'ActionMailer::Base'
|
34
|
+
|
35
|
+
# ==> ORM configuration
|
36
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
37
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
38
|
+
# available as additional gems.
|
39
|
+
require 'devise/orm/active_record'
|
40
|
+
|
41
|
+
# ==> Configuration for any authentication mechanism
|
42
|
+
# Configure which keys are used when authenticating a user. The default is
|
43
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
44
|
+
# authenticating a user, both parameters are required. Remember that those
|
45
|
+
# parameters are used only when authenticating and not when retrieving from
|
46
|
+
# session. If you need permissions, you should implement that in a before filter.
|
47
|
+
# You can also supply a hash where the value is a boolean determining whether
|
48
|
+
# or not authentication should be aborted when the value is not present.
|
49
|
+
# config.authentication_keys = [:email]
|
50
|
+
|
51
|
+
# Configure parameters from the request object used for authentication. Each entry
|
52
|
+
# given should be a request method and it will automatically be passed to the
|
53
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
54
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
55
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
56
|
+
# config.request_keys = []
|
57
|
+
|
58
|
+
# Configure which authentication keys should be case-insensitive.
|
59
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
60
|
+
# to authenticate or find a user. Default is :email.
|
61
|
+
config.case_insensitive_keys = [:email]
|
62
|
+
|
63
|
+
# Configure which authentication keys should have whitespace stripped.
|
64
|
+
# These keys will have whitespace before and after removed upon creating or
|
65
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
66
|
+
config.strip_whitespace_keys = [:email]
|
67
|
+
|
68
|
+
# Tell if authentication through request.params is enabled. True by default.
|
69
|
+
# It can be set to an array that will enable params authentication only for the
|
70
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
71
|
+
# enable it only for database (email + password) authentication.
|
72
|
+
# config.params_authenticatable = true
|
73
|
+
|
74
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
75
|
+
# It can be set to an array that will enable http authentication only for the
|
76
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
77
|
+
# enable it only for database authentication.
|
78
|
+
# For API-only applications to support authentication "out-of-the-box", you will likely want to
|
79
|
+
# enable this with :database unless you are using a custom strategy.
|
80
|
+
# The supported strategies are:
|
81
|
+
# :database = Support basic authentication with authentication key + password
|
82
|
+
# config.http_authenticatable = false
|
83
|
+
|
84
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
85
|
+
# config.http_authenticatable_on_xhr = true
|
86
|
+
|
87
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
88
|
+
# config.http_authentication_realm = 'Application'
|
89
|
+
|
90
|
+
# It will change confirmation, password recovery and other workflows
|
91
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
92
|
+
# Does not affect registerable.
|
93
|
+
# config.paranoid = true
|
94
|
+
|
95
|
+
# By default Devise will store the user in session. You can skip storage for
|
96
|
+
# particular strategies by setting this option.
|
97
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
98
|
+
# may want to disable generating routes to Devise's sessions controller by
|
99
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
100
|
+
config.skip_session_storage = [:http_auth]
|
101
|
+
|
102
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
103
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
104
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
105
|
+
# from the server. You can disable this option at your own risk.
|
106
|
+
# config.clean_up_csrf_token_on_authentication = true
|
107
|
+
|
108
|
+
# When false, Devise will not attempt to reload routes on eager load.
|
109
|
+
# This can reduce the time taken to boot the app but if your application
|
110
|
+
# requires the Devise mappings to be loaded during boot time the application
|
111
|
+
# won't boot properly.
|
112
|
+
# config.reload_routes = true
|
113
|
+
|
114
|
+
# ==> Configuration for :database_authenticatable
|
115
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
|
116
|
+
# using other algorithms, it sets how many times you want the password to be hashed.
|
117
|
+
# The number of stretches used for generating the hashed password are stored
|
118
|
+
# with the hashed password. This allows you to change the stretches without
|
119
|
+
# invalidating existing passwords.
|
120
|
+
#
|
121
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
122
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
123
|
+
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
124
|
+
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
125
|
+
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
126
|
+
config.stretches = Rails.env.test? ? 1 : 12
|
127
|
+
|
128
|
+
# Set up a pepper to generate the hashed password.
|
129
|
+
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
130
|
+
|
131
|
+
# Send a notification to the original email when the user's email is changed.
|
132
|
+
# config.send_email_changed_notification = false
|
133
|
+
|
134
|
+
# Send a notification email when the user's password is changed.
|
135
|
+
# config.send_password_change_notification = false
|
136
|
+
|
137
|
+
# ==> Configuration for :confirmable
|
138
|
+
# A period that the user is allowed to access the website even without
|
139
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
140
|
+
# able to access the website for two days without confirming their account,
|
141
|
+
# access will be blocked just in the third day.
|
142
|
+
# You can also set it to nil, which will allow the user to access the website
|
143
|
+
# without confirming their account.
|
144
|
+
# Default is 0.days, meaning the user cannot access the website without
|
145
|
+
# confirming their account.
|
146
|
+
# config.allow_unconfirmed_access_for = 2.days
|
147
|
+
|
148
|
+
# A period that the user is allowed to confirm their account before their
|
149
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
150
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
151
|
+
# their account can't be confirmed with the token any more.
|
152
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
153
|
+
# before confirming their account.
|
154
|
+
# config.confirm_within = 3.days
|
155
|
+
|
156
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
157
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
158
|
+
# db field (see migrations). Until confirmed, new email is stored in
|
159
|
+
# unconfirmed_email column, and copied to email column on successful confirmation.
|
160
|
+
config.reconfirmable = true
|
161
|
+
|
162
|
+
# Defines which key will be used when confirming an account
|
163
|
+
# config.confirmation_keys = [:email]
|
164
|
+
|
165
|
+
# ==> Configuration for :rememberable
|
166
|
+
# The time the user will be remembered without asking for credentials again.
|
167
|
+
# config.remember_for = 2.weeks
|
168
|
+
|
169
|
+
# Invalidates all the remember me tokens when the user signs out.
|
170
|
+
config.expire_all_remember_me_on_sign_out = true
|
171
|
+
|
172
|
+
# If true, extends the user's remember period when remembered via cookie.
|
173
|
+
# config.extend_remember_period = false
|
174
|
+
|
175
|
+
# Options to be passed to the created cookie. For instance, you can set
|
176
|
+
# secure: true in order to force SSL only cookies.
|
177
|
+
# config.rememberable_options = {}
|
178
|
+
|
179
|
+
# ==> Configuration for :validatable
|
180
|
+
# Range for password length.
|
181
|
+
config.password_length = 6..128
|
182
|
+
|
183
|
+
# Email regex used to validate email formats. It simply asserts that
|
184
|
+
# one (and only one) @ exists in the given string. This is mainly
|
185
|
+
# to give user feedback and not to assert the e-mail validity.
|
186
|
+
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
187
|
+
|
188
|
+
# ==> Configuration for :timeoutable
|
189
|
+
# The time you want to timeout the user session without activity. After this
|
190
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
191
|
+
# config.timeout_in = 30.minutes
|
192
|
+
|
193
|
+
# ==> Configuration for :lockable
|
194
|
+
# Defines which strategy will be used to lock an account.
|
195
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
196
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
197
|
+
# config.lock_strategy = :failed_attempts
|
198
|
+
|
199
|
+
# Defines which key will be used when locking and unlocking an account
|
200
|
+
# config.unlock_keys = [:email]
|
201
|
+
|
202
|
+
# Defines which strategy will be used to unlock an account.
|
203
|
+
# :email = Sends an unlock link to the user email
|
204
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
205
|
+
# :both = Enables both strategies
|
206
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
207
|
+
# config.unlock_strategy = :both
|
208
|
+
|
209
|
+
# Number of authentication tries before locking an account if lock_strategy
|
210
|
+
# is failed attempts.
|
211
|
+
# config.maximum_attempts = 20
|
212
|
+
|
213
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
214
|
+
# config.unlock_in = 1.hour
|
215
|
+
|
216
|
+
# Warn on the last attempt before the account is locked.
|
217
|
+
# config.last_attempt_warning = true
|
218
|
+
|
219
|
+
# ==> Configuration for :recoverable
|
220
|
+
#
|
221
|
+
# Defines which key will be used when recovering the password for an account
|
222
|
+
# config.reset_password_keys = [:email]
|
223
|
+
|
224
|
+
# Time interval you can reset your password with a reset password key.
|
225
|
+
# Don't put a too small interval or your users won't have the time to
|
226
|
+
# change their passwords.
|
227
|
+
config.reset_password_within = 6.hours
|
228
|
+
|
229
|
+
# When set to false, does not sign a user in automatically after their password is
|
230
|
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
231
|
+
# config.sign_in_after_reset_password = true
|
232
|
+
|
233
|
+
# ==> Configuration for :encryptable
|
234
|
+
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
|
235
|
+
# You can use :sha1, :sha512 or algorithms from others authentication tools as
|
236
|
+
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
|
237
|
+
# for default behavior) and :restful_authentication_sha1 (then you should set
|
238
|
+
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
|
239
|
+
#
|
240
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
241
|
+
# config.encryptor = :sha512
|
242
|
+
|
243
|
+
# ==> Scopes configuration
|
244
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
245
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
246
|
+
# are using only default views.
|
247
|
+
# config.scoped_views = false
|
248
|
+
|
249
|
+
# Configure the default scope given to Warden. By default it's the first
|
250
|
+
# devise role declared in your routes (usually :user).
|
251
|
+
# config.default_scope = :user
|
252
|
+
|
253
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
254
|
+
# only the current scope. By default, Devise signs out all scopes.
|
255
|
+
# config.sign_out_all_scopes = true
|
256
|
+
|
257
|
+
# ==> Navigation configuration
|
258
|
+
# Lists the formats that should be treated as navigational. Formats like
|
259
|
+
# :html should redirect to the sign in page when the user does not have
|
260
|
+
# access, but formats like :xml or :json, should return 401.
|
261
|
+
#
|
262
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
263
|
+
# should add them to the navigational formats lists.
|
264
|
+
#
|
265
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
266
|
+
# config.navigational_formats = ['*/*', :html, :turbo_stream]
|
267
|
+
|
268
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
269
|
+
config.sign_out_via = :delete
|
270
|
+
|
271
|
+
# ==> OmniAuth
|
272
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
273
|
+
# up on your models and hooks.
|
274
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
275
|
+
identity_base_url = ENV['IDENTITY_BASE_URL'] || "https://devlogin.strongmind.com"
|
276
|
+
app_base_url = ENV['APP_BASE_URL'] || "http://localhost:3000"
|
277
|
+
config.omniauth :openid_connect, {
|
278
|
+
name: :strongmind,
|
279
|
+
scope: %i[openid profile],
|
280
|
+
response_type: :code,
|
281
|
+
issuer: identity_base_url,
|
282
|
+
discovery: true,
|
283
|
+
post_logout_redirect_uri: app_base_url,
|
284
|
+
client_options: {
|
285
|
+
identifier: ENV['IDENTITY_CLIENT_ID'],
|
286
|
+
secret: ENV['IDENTITY_CLIENT_SECRET'],
|
287
|
+
redirect_uri: "#{app_base_url}/users/auth/strongmind/callback"
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
# ==> Warden configuration
|
292
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
293
|
+
# change the failure app, you can configure them inside the config.warden block.
|
294
|
+
#
|
295
|
+
# config.warden do |manager|
|
296
|
+
# manager.intercept_401 = false
|
297
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
298
|
+
# end
|
299
|
+
|
300
|
+
# ==> Mountable engine configurations
|
301
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
302
|
+
# is mountable, there are some extra configurations to be taken into account.
|
303
|
+
# The following options are available, assuming the engine is mounted as:
|
304
|
+
#
|
305
|
+
# mount MyEngine, at: '/my_engine'
|
306
|
+
#
|
307
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
308
|
+
# config.router_name = :my_engine
|
309
|
+
#
|
310
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
311
|
+
# so you need to do it manually. For the users scope, it would be:
|
312
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
313
|
+
|
314
|
+
# ==> Hotwire/Turbo configuration
|
315
|
+
# When using Devise with Hotwire/Turbo, the http status for error responses
|
316
|
+
# and some redirects must match the following. The default in Devise for existing
|
317
|
+
# apps is `200 OK` and `302 Found respectively`, but new apps are generated with
|
318
|
+
# these new defaults that match Hotwire/Turbo behavior.
|
319
|
+
# Note: These might become the new default in future versions of Devise.
|
320
|
+
config.responder.error_status = :unprocessable_entity
|
321
|
+
config.responder.redirect_status = :see_other
|
322
|
+
|
323
|
+
# ==> Configuration for :registerable
|
324
|
+
|
325
|
+
# When set to false, does not sign a user in automatically after their password is
|
326
|
+
# changed. Defaults to true, so a user is signed in automatically after changing a password.
|
327
|
+
# config.sign_in_after_change_password = true
|
328
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Users
|
4
|
+
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
5
|
+
|
6
|
+
def strongmind
|
7
|
+
# Sign in the user
|
8
|
+
@user = User.from_omniauth(request.env['omniauth.auth'])
|
9
|
+
sign_in_and_redirect @user
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure
|
13
|
+
redirect_to root_url
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
Hi <%= current_user.auth.extra.raw_info['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname'] %>
|
2
|
+
<%= current_user.auth.extra.raw_info['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname'] %>!
|
3
|
+
<%= button_to 'Sign out', '/users/sign_out', style: 'display:inline' %>
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongmind-platform-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platform Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -72,6 +72,62 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.66'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: devise
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: omniauth
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: omniauth-rails_csrf_protection
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: omniauth_openid_connect
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
75
131
|
description: Includes a wrapper for the swagger generated OneRoster management clients
|
76
132
|
email:
|
77
133
|
- horseshoes@strongmind.com
|
@@ -91,6 +147,14 @@ files:
|
|
91
147
|
- Makefile
|
92
148
|
- README.md
|
93
149
|
- Rakefile
|
150
|
+
- docs/identity_installation_in_rails.md
|
151
|
+
- lib/generators/strong_mind_rails_identity/install_generator.rb
|
152
|
+
- lib/generators/templates/add_uid_to_user.rb
|
153
|
+
- lib/generators/templates/devise.rb
|
154
|
+
- lib/generators/templates/omniauth_callbacks_controller.rb
|
155
|
+
- lib/generators/templates/strong_mind_auto_login.html.erb
|
156
|
+
- lib/generators/templates/strong_mind_auto_login.signed_in.html.erb
|
157
|
+
- lib/generators/templates/strong_mind_auto_login_controller.rb
|
94
158
|
- lib/platform_sdk.rb
|
95
159
|
- lib/platform_sdk/aws.rb
|
96
160
|
- lib/platform_sdk/aws/secrets_manager_client.rb
|
@@ -115,7 +179,7 @@ metadata:
|
|
115
179
|
homepage_uri: https://github.com/StrongMind/platform-ruby-sdk
|
116
180
|
source_code_uri: https://github.com/StrongMind/platform-ruby-sdk
|
117
181
|
changelog_uri: https://github.com/StrongMind/platform-ruby-sdk/blob/main/CHANGELOG.md
|
118
|
-
post_install_message:
|
182
|
+
post_install_message:
|
119
183
|
rdoc_options: []
|
120
184
|
require_paths:
|
121
185
|
- lib
|
@@ -131,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
195
|
version: '0'
|
132
196
|
requirements: []
|
133
197
|
rubygems_version: 3.3.26
|
134
|
-
signing_key:
|
198
|
+
signing_key:
|
135
199
|
specification_version: 4
|
136
200
|
summary: This gem is intended to provide clients and models for accessing the Platform
|
137
201
|
APIs.
|