Skip to content

Commit f3a4ee8

Browse files
committed
Complete oAuth2 endpoints
1 parent 1ba4714 commit f3a4ee8

File tree

6 files changed

+60
-61
lines changed

6 files changed

+60
-61
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ FACEBOOK_APP_ID=
1717
FACEBOOK_SECRET=
1818

1919
# Omniauth Microsoft/Azure oAuth2
20-
AZURE_APP_ID=
21-
AZURE_SECRET=
20+
MICROSOFT_APP_ID=
21+
MICROSOFT_SECRET=

Gemfile.lock

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (6.0.3.2)
5-
actionpack (= 6.0.3.2)
4+
actioncable (6.0.3.3)
5+
actionpack (= 6.0.3.3)
66
nio4r (~> 2.0)
77
websocket-driver (>= 0.6.1)
8-
actionmailbox (6.0.3.2)
9-
actionpack (= 6.0.3.2)
10-
activejob (= 6.0.3.2)
11-
activerecord (= 6.0.3.2)
12-
activestorage (= 6.0.3.2)
13-
activesupport (= 6.0.3.2)
8+
actionmailbox (6.0.3.3)
9+
actionpack (= 6.0.3.3)
10+
activejob (= 6.0.3.3)
11+
activerecord (= 6.0.3.3)
12+
activestorage (= 6.0.3.3)
13+
activesupport (= 6.0.3.3)
1414
mail (>= 2.7.1)
15-
actionmailer (6.0.3.2)
16-
actionpack (= 6.0.3.2)
17-
actionview (= 6.0.3.2)
18-
activejob (= 6.0.3.2)
15+
actionmailer (6.0.3.3)
16+
actionpack (= 6.0.3.3)
17+
actionview (= 6.0.3.3)
18+
activejob (= 6.0.3.3)
1919
mail (~> 2.5, >= 2.5.4)
2020
rails-dom-testing (~> 2.0)
21-
actionpack (6.0.3.2)
22-
actionview (= 6.0.3.2)
23-
activesupport (= 6.0.3.2)
21+
actionpack (6.0.3.3)
22+
actionview (= 6.0.3.3)
23+
activesupport (= 6.0.3.3)
2424
rack (~> 2.0, >= 2.0.8)
2525
rack-test (>= 0.6.3)
2626
rails-dom-testing (~> 2.0)
2727
rails-html-sanitizer (~> 1.0, >= 1.2.0)
28-
actiontext (6.0.3.2)
29-
actionpack (= 6.0.3.2)
30-
activerecord (= 6.0.3.2)
31-
activestorage (= 6.0.3.2)
32-
activesupport (= 6.0.3.2)
28+
actiontext (6.0.3.3)
29+
actionpack (= 6.0.3.3)
30+
activerecord (= 6.0.3.3)
31+
activestorage (= 6.0.3.3)
32+
activesupport (= 6.0.3.3)
3333
nokogiri (>= 1.8.5)
34-
actionview (6.0.3.2)
35-
activesupport (= 6.0.3.2)
34+
actionview (6.0.3.3)
35+
activesupport (= 6.0.3.3)
3636
builder (~> 3.1)
3737
erubi (~> 1.4)
3838
rails-dom-testing (~> 2.0)
3939
rails-html-sanitizer (~> 1.1, >= 1.2.0)
40-
activejob (6.0.3.2)
41-
activesupport (= 6.0.3.2)
40+
activejob (6.0.3.3)
41+
activesupport (= 6.0.3.3)
4242
globalid (>= 0.3.6)
43-
activemodel (6.0.3.2)
44-
activesupport (= 6.0.3.2)
45-
activerecord (6.0.3.2)
46-
activemodel (= 6.0.3.2)
47-
activesupport (= 6.0.3.2)
48-
activestorage (6.0.3.2)
49-
actionpack (= 6.0.3.2)
50-
activejob (= 6.0.3.2)
51-
activerecord (= 6.0.3.2)
43+
activemodel (6.0.3.3)
44+
activesupport (= 6.0.3.3)
45+
activerecord (6.0.3.3)
46+
activemodel (= 6.0.3.3)
47+
activesupport (= 6.0.3.3)
48+
activestorage (6.0.3.3)
49+
actionpack (= 6.0.3.3)
50+
activejob (= 6.0.3.3)
51+
activerecord (= 6.0.3.3)
5252
marcel (~> 0.3.1)
53-
activesupport (6.0.3.2)
53+
activesupport (6.0.3.3)
5454
concurrent-ruby (~> 1.0, >= 1.0.2)
5555
i18n (>= 0.7, < 2)
5656
minitest (~> 5.1)
@@ -111,7 +111,7 @@ GEM
111111
carmen
112112
coffee-rails
113113
rails (>= 3.2.0)
114-
effective_bootstrap (0.8.3)
114+
effective_bootstrap (0.8.4)
115115
bootstrap (>= 4.0.0)
116116
coffee-rails
117117
inline_svg
@@ -276,20 +276,20 @@ GEM
276276
rack-test (1.1.0)
277277
rack (>= 1.0, < 3)
278278
rack-timeout (0.6.0)
279-
rails (6.0.3.2)
280-
actioncable (= 6.0.3.2)
281-
actionmailbox (= 6.0.3.2)
282-
actionmailer (= 6.0.3.2)
283-
actionpack (= 6.0.3.2)
284-
actiontext (= 6.0.3.2)
285-
actionview (= 6.0.3.2)
286-
activejob (= 6.0.3.2)
287-
activemodel (= 6.0.3.2)
288-
activerecord (= 6.0.3.2)
289-
activestorage (= 6.0.3.2)
290-
activesupport (= 6.0.3.2)
279+
rails (6.0.3.3)
280+
actioncable (= 6.0.3.3)
281+
actionmailbox (= 6.0.3.3)
282+
actionmailer (= 6.0.3.3)
283+
actionpack (= 6.0.3.3)
284+
actiontext (= 6.0.3.3)
285+
actionview (= 6.0.3.3)
286+
activejob (= 6.0.3.3)
287+
activemodel (= 6.0.3.3)
288+
activerecord (= 6.0.3.3)
289+
activestorage (= 6.0.3.3)
290+
activesupport (= 6.0.3.3)
291291
bundler (>= 1.3.0)
292-
railties (= 6.0.3.2)
292+
railties (= 6.0.3.3)
293293
sprockets-rails (>= 2.0.0)
294294
rails-dom-testing (2.0.3)
295295
activesupport (>= 4.2.0)
@@ -301,9 +301,9 @@ GEM
301301
rails_stdout_logging
302302
rails_serve_static_assets (0.0.5)
303303
rails_stdout_logging (0.0.5)
304-
railties (6.0.3.2)
305-
actionpack (= 6.0.3.2)
306-
activesupport (= 6.0.3.2)
304+
railties (6.0.3.3)
305+
actionpack (= 6.0.3.3)
306+
activesupport (= 6.0.3.3)
307307
method_source
308308
rake (>= 0.8.7)
309309
thor (>= 0.20.3, < 2.0)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ GOOGLE_SECRET=
228228
- Copy the Client secret into the `.env` file and/or set server production ENV variables
229229

230230
```
231-
AZURE_APP_ID=
232-
AZURE_SECRET=
231+
MICROSOFT_APP_ID=
232+
MICROSOFT_SECRET=
233233
```
234234

235235
## License

app/models/user.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def self.from_omniauth(auth, params)
105105
email = (auth.info.email.presence || "#{auth.uid}@#{auth.provider}.none").downcase
106106
image = auth.info.image
107107
name = auth.info.name || auth.dig(:extra, :raw_info, :login)
108-
info = auth.dig(:extra, :raw_info).to_h.symbolize_keys
109108

110109
user = if invitation_token
111110
User.find_by_invitation_token(invitation_token, false) || raise(ActiveRecord::RecordNotFound)
@@ -119,8 +118,8 @@ def self.from_omniauth(auth, params)
119118
email: email,
120119
avatar_url: image,
121120
name: name,
122-
first_name: auth.info.first_name.presence || name.split(' ').first,
123-
last_name: auth.info.last_name || name.split(' ').last
121+
first_name: (auth.info.first_name.presence || name.split(' ').first.presence || 'First'),
122+
last_name: (auth.info.last_name.presence || name.split(' ').last.presence || 'Last')
124123
)
125124

126125
if auth.respond_to?(:credentials)

config/initializers/devise.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@
316316
}
317317
end
318318

319-
if ENV['AZURE_APP_ID'].present? && defined?(OmniAuth::Strategies::MicrosoftGraph)
320-
config.omniauth :microsoft_graph, ENV.fetch('AZURE_APP_ID'), ENV.fetch('AZURE_SECRET'), {
319+
if ENV['MICROSOFT_ID'].present? && defined?(OmniAuth::Strategies::MicrosoftGraph)
320+
config.omniauth :microsoft_graph, ENV.fetch('MICROSOFT_ID'), ENV.fetch('MICROSOFT_SECRET'), {
321321
scope: 'openid profile email offline_access user.read'
322322
}
323323
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Be sure to restart your server when you modify this file.
22

33
# Configure sensitive parameters which will be filtered from the log file.
4-
Rails.application.config.filter_parameters += [:password]
4+
Rails.application.config.filter_parameters += [:password, :access_token, :refresh_token]

0 commit comments

Comments
 (0)