Skip to content

Commit e1dce76

Browse files
authored
Use ombu_labs-auth for authentication (#297)
* Use ombu_labs-auth for the authentication * Add env to README * Update gemfile.next.lock
1 parent 4684eac commit e1dce76

14 files changed

Lines changed: 90 additions & 432 deletions

File tree

Gemfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ if next?
1717
# read more about it here: https://github.com/rails/rails/issues/43998,
1818
# and here: https://gist.github.com/claudiug/bdc2fb70b10d19513208c816588aed92
1919
gem "rails", github: "rails/rails", branch: "7-0-stable"
20-
gem "devise", github: "heartcombo/devise", branch: "main"
2120
else
2221
gem "rails", "~> 7.0.2"
23-
gem "devise"
2422
end
2523
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
2624

@@ -61,8 +59,7 @@ gem "acts_as_list"
6159

6260
gem "mimemagic", "~> 0.3.8"
6361

64-
gem "omniauth-github", "~> 2.0.0"
65-
gem "omniauth-rails_csrf_protection"
62+
gem "ombu_labs-auth"
6663

6764
gem "rack-mini-profiler"
6865

Gemfile.lock

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ GEM
117117
database_cleaner-core (~> 2.0.0)
118118
database_cleaner-core (2.0.1)
119119
date (3.3.3)
120-
devise (4.9.1)
120+
devise (4.8.1)
121121
bcrypt (~> 3.0)
122122
orm_adapter (~> 0.1)
123123
railties (>= 4.1.0)
@@ -209,6 +209,12 @@ GEM
209209
rack (>= 1.2, < 4)
210210
snaky_hash (~> 2.0)
211211
version_gem (~> 1.1)
212+
ombu_labs-auth (1.0.0)
213+
devise (~> 4.8.1)
214+
omniauth (~> 2.1.0)
215+
omniauth-github (~> 2.0.0)
216+
omniauth-rails_csrf_protection
217+
rails (>= 6.0)
212218
omniauth (2.1.1)
213219
hashie (>= 3.4.6)
214220
rack (>= 2.2.3)
@@ -406,7 +412,6 @@ DEPENDENCIES
406412
capybara-screenshot
407413
coffee-script
408414
database_cleaner
409-
devise
410415
dotenv-rails
411416
factory_bot_rails
412417
faker
@@ -419,8 +424,7 @@ DEPENDENCIES
419424
mimemagic (~> 0.3.8)
420425
newrelic_rpm
421426
next_rails
422-
omniauth-github (~> 2.0.0)
423-
omniauth-rails_csrf_protection
427+
ombu_labs-auth
424428
pg
425429
puma (~> 6.2)
426430
pundit (~> 2.2)

Gemfile.next.lock

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
GIT
2-
remote: https://github.com/heartcombo/devise.git
3-
revision: 8593801130f2df94a50863b5db535c272b00efe1
4-
branch: main
5-
specs:
6-
devise (4.8.0)
7-
bcrypt (~> 3.0)
8-
orm_adapter (~> 0.1)
9-
railties (>= 4.1.0)
10-
responders
11-
warden (~> 1.2.3)
12-
131
GIT
142
remote: https://github.com/rails/rails.git
153
revision: 4408b67742cb7ee3cdc3b3d850e1a3be205bd4e6
@@ -121,7 +109,7 @@ GEM
121109
ast (2.4.2)
122110
autoprefixer-rails (10.3.3.0)
123111
execjs (~> 2)
124-
bcrypt (3.1.16)
112+
bcrypt (3.1.18)
125113
bindex (0.8.1)
126114
bootstrap-sass (3.4.1)
127115
autoprefixer-rails (>= 5.2.1)
@@ -157,6 +145,12 @@ GEM
157145
database_cleaner-core (~> 2.0.0)
158146
database_cleaner-core (2.0.1)
159147
date (3.3.3)
148+
devise (4.8.1)
149+
bcrypt (~> 3.0)
150+
orm_adapter (~> 0.1)
151+
railties (>= 4.1.0)
152+
responders
153+
warden (~> 1.2.3)
160154
diff-lcs (1.4.4)
161155
docile (1.4.0)
162156
dotenv (2.7.6)
@@ -172,29 +166,14 @@ GEM
172166
railties (>= 5.0.0)
173167
faker (2.19.0)
174168
i18n (>= 1.6, < 2)
175-
faraday (1.8.0)
176-
faraday-em_http (~> 1.0)
177-
faraday-em_synchrony (~> 1.0)
178-
faraday-excon (~> 1.1)
179-
faraday-httpclient (~> 1.0.1)
180-
faraday-net_http (~> 1.0)
181-
faraday-net_http_persistent (~> 1.1)
182-
faraday-patron (~> 1.0)
183-
faraday-rack (~> 1.0)
184-
multipart-post (>= 1.2, < 3)
169+
faraday (2.7.6)
170+
faraday-net_http (>= 2.0, < 3.1)
185171
ruby2_keywords (>= 0.0.4)
186-
faraday-em_http (1.0.0)
187-
faraday-em_synchrony (1.0.0)
188-
faraday-excon (1.1.0)
189-
faraday-httpclient (1.0.1)
190-
faraday-net_http (1.0.1)
191-
faraday-net_http_persistent (1.2.0)
192-
faraday-patron (1.0.0)
193-
faraday-rack (1.0.0)
172+
faraday-net_http (3.0.2)
194173
ffi (1.15.4)
195174
globalid (1.1.0)
196175
activesupport (>= 5.0)
197-
hashie (4.1.0)
176+
hashie (5.0.0)
198177
i18n (1.12.0)
199178
concurrent-ruby (~> 1.0)
200179
jbuilder (2.11.2)
@@ -205,7 +184,7 @@ GEM
205184
thor (>= 0.14, < 2.0)
206185
jquery-ui-rails (5.0.5)
207186
railties (>= 3.2.16)
208-
jwt (2.3.0)
187+
jwt (2.7.1)
209188
launchy (2.5.0)
210189
addressable (~> 2.7)
211190
listen (3.7.0)
@@ -214,6 +193,9 @@ GEM
214193
loofah (2.19.1)
215194
crass (~> 1.0.2)
216195
nokogiri (>= 1.5.9)
196+
madmin (1.2.8)
197+
pagy (>= 3.5)
198+
rails (>= 6.0.3)
217199
mail (2.8.1)
218200
mini_mime (>= 0.1.1)
219201
net-imap
@@ -228,9 +210,7 @@ GEM
228210
mini_mime (1.1.2)
229211
mini_portile2 (2.8.1)
230212
minitest (5.18.0)
231-
multi_json (1.15.0)
232213
multi_xml (0.6.0)
233-
multipart-post (2.1.1)
234214
net-imap (0.3.4)
235215
date
236216
net-protocol
@@ -249,26 +229,34 @@ GEM
249229
racc (~> 1.4)
250230
nokogiri (1.14.2-x86_64-linux)
251231
racc (~> 1.4)
252-
oauth2 (1.4.7)
253-
faraday (>= 0.8, < 2.0)
232+
oauth2 (2.0.9)
233+
faraday (>= 0.17.3, < 3.0)
254234
jwt (>= 1.0, < 3.0)
255-
multi_json (~> 1.3)
256235
multi_xml (~> 0.5)
257-
rack (>= 1.2, < 3)
258-
omniauth (2.0.4)
236+
rack (>= 1.2, < 4)
237+
snaky_hash (~> 2.0)
238+
version_gem (~> 1.1)
239+
ombu_labs-auth (1.0.0)
240+
devise (~> 4.8.1)
241+
omniauth (~> 2.1.0)
242+
omniauth-github (~> 2.0.0)
243+
omniauth-rails_csrf_protection
244+
rails (>= 6.0)
245+
omniauth (2.1.1)
259246
hashie (>= 3.4.6)
260-
rack (>= 1.6.2, < 3)
247+
rack (>= 2.2.3)
261248
rack-protection
262-
omniauth-github (2.0.0)
249+
omniauth-github (2.0.1)
250+
omniauth (~> 2.0)
251+
omniauth-oauth2 (~> 1.8)
252+
omniauth-oauth2 (1.8.0)
253+
oauth2 (>= 1.4, < 3)
263254
omniauth (~> 2.0)
264-
omniauth-oauth2 (~> 1.7.1)
265-
omniauth-oauth2 (1.7.1)
266-
oauth2 (~> 1.4)
267-
omniauth (>= 1.9, < 3)
268-
omniauth-rails_csrf_protection (1.0.0)
255+
omniauth-rails_csrf_protection (1.0.1)
269256
actionpack (>= 4.2)
270257
omniauth (~> 2.0)
271258
orm_adapter (0.5.0)
259+
pagy (6.0.4)
272260
parallel (1.21.0)
273261
parser (3.0.2.0)
274262
ast (~> 2.4.1)
@@ -282,7 +270,7 @@ GEM
282270
rack (2.2.6.4)
283271
rack-mini-profiler (3.0.0)
284272
rack (>= 1.2.0)
285-
rack-protection (2.1.0)
273+
rack-protection (3.0.6)
286274
rack
287275
rack-test (2.1.0)
288276
rack (>= 1.3)
@@ -303,9 +291,9 @@ GEM
303291
recursive-open-struct (1.1.3)
304292
redcarpet (3.5.1)
305293
regexp_parser (2.7.0)
306-
responders (3.0.1)
307-
actionpack (>= 5.0)
308-
railties (>= 5.0)
294+
responders (3.1.0)
295+
actionpack (>= 5.2)
296+
railties (>= 5.2)
309297
rexml (3.2.5)
310298
rspec-core (3.10.1)
311299
rspec-support (~> 3.10.0)
@@ -365,6 +353,9 @@ GEM
365353
simplecov_json_formatter (~> 0.1)
366354
simplecov-html (0.12.3)
367355
simplecov_json_formatter (0.1.3)
356+
snaky_hash (2.0.1)
357+
hashie
358+
version_gem (~> 1.1, >= 1.1.1)
368359
spring (3.0.0)
369360
sprockets (3.7.2)
370361
concurrent-ruby (~> 1.0)
@@ -389,6 +380,7 @@ GEM
389380
uglifier (4.2.0)
390381
execjs (>= 0.3.0, < 3)
391382
unicode-display_width (2.1.0)
383+
version_gem (1.1.3)
392384
warden (1.2.9)
393385
rack (>= 2.0.9)
394386
web-console (4.1.0)
@@ -421,20 +413,19 @@ DEPENDENCIES
421413
capybara-screenshot
422414
coffee-script
423415
database_cleaner
424-
devise!
425416
dotenv-rails
426417
factory_bot_rails
427418
faker
428419
jbuilder (~> 2.5)
429420
jquery-rails
430421
jquery-ui-rails (~> 5.0, >= 5.0.5)
431422
listen (~> 3.7)
423+
madmin (~> 1.2)
432424
matrix
433425
mimemagic (~> 0.3.8)
434426
newrelic_rpm
435427
next_rails
436-
omniauth-github (~> 2.0.0)
437-
omniauth-rails_csrf_protection
428+
ombu_labs-auth
438429
pg
439430
puma (~> 6.2)
440431
pundit (~> 2.2)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ GITHUB_APP_ID=xxxxxxxxxxxxxxxxxxxx
3636
GITHUB_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3737
```
3838

39+
`SHOW_DEVELOPER_AUTH=true` can be used to allow easy login without requiring GitHub's setup during local development or in safe review environments.
40+
3941
## Starting the Server
4042

4143
```

app/controllers/callbacks_controller.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.

app/controllers/registrations_controller.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/models/user.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
class User < ApplicationRecord
2-
# Include default devise modules. Others available are:
3-
# :confirmable, :lockable, :timeoutable and :omniauthable
4-
devise :database_authenticatable, :registerable,
5-
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
2+
include OmbuLabsAuthenticable
63

74
has_many :estimates
8-
9-
def self.from_omniauth(auth)
10-
user_attributes = {
11-
email: auth.info.email,
12-
name: auth.info.name,
13-
password: Devise.friendly_token[0, 20]
14-
}
15-
where(provider: auth.provider, uid: auth.uid).first_or_create.tap { |user| user.update(user_attributes) }
16-
end
175
end

app/views/home/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="fluid-container center floor signin">
22
<h1>Welcome to the Points App</h1>
3-
<%= link_to "Sign in", new_user_session_path, class: "button green", id: "edit" %>
3+
<%= link_to "Sign in", ombu_labs_auth.new_user_session_path, class: "button green", id: "edit" %>
44
</div>

app/views/layouts/_header.html.erb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
<%- title = defined?(header_title) ? header_title : "points app" %>
2+
<%- link = defined?(header_link) ? header_link : "/projects" %>
3+
14
<header class="navbar navbar-inverse">
25
<div class="container">
36
<div class="row">
47
<div class="col-xs-10">
5-
<%= link_to header_title, header_link, id: "logo" %>
8+
<%= link_to title, link, id: "logo" %>
69
</div>
710
<div class="col-xs-2">
811
<nav>
912
<ul class="nav">
1013
<% if current_user %>
11-
<%= link_to "Sign out", destroy_user_session_path, method: :delete, class: "button magenta" %>
14+
<%= link_to "Sign out", ombu_labs_auth.destroy_user_session_path, method: :delete, class: "button magenta" %>
1215
<% else %>
13-
<%= link_to "Sign in", new_user_session_path, class: "button green" %>
16+
<%= link_to "Sign in", ombu_labs_auth.new_user_session_path, class: "button green" %>
1417
<% end %>
1518
</ul>
1619
</nav>

app/views/layouts/devise.html.erb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Points - Sign in</title>
5+
<%= csrf_meta_tags %>
6+
<!-- Fonts -->
7+
<link href='https://fonts.googleapis.com/css?family=Lato:700|Open+Sans:400,300,300italic,400italic,700,700italic' rel='stylesheet' type='text/css'>
8+
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
9+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
10+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
11+
</head>
12+
<body class="content <%= controller_name %>-controller <%= action_name %>-action">
13+
<%= render 'layouts/header' %>
14+
<div>
15+
<main class="fluid-container">
16+
<%= render 'layouts/flash' %>
17+
<%= yield %>
18+
</main>
19+
<%= render 'layouts/footer' %>
20+
</div>
21+
<%= render 'layouts/modal' %>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)