Skip to content

Commit bc63056

Browse files
committed
upgrade to omniauth-cas 3.0
omniauth-cas now requires a switch from a GET to POST, which leads us to need to modify how our login links exist and are styled (i.e., they are no longer truly links but rather forms).
1 parent 459ee58 commit bc63056

File tree

6 files changed

+50
-18
lines changed

6 files changed

+50
-18
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ gem 'jbuilder', '~> 2.13'
1313
gem 'nokogiri', '~> 1.18'
1414
# gem 'non-stupid-digest-assets', '~> 1.0' # Allow static pages (e.g. 404.html) to link to compiled assets
1515
gem 'okcomputer', '~> 1.19'
16-
gem 'omniauth-cas', '~> 2.0'
16+
gem 'omniauth-cas', '~> 3.0'
17+
gem 'omniauth-rails_csrf_protection', '~> 1.0'
1718
gem 'puma', '~> 5.3', '>= 5.3.1'
1819
gem 'rails', '~> 8.0.4'
1920
gem 'rest-client', '~> 2.1'

Gemfile.lock

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ GEM
7272
securerandom (>= 0.3)
7373
tzinfo (~> 2.0, >= 2.0.5)
7474
uri (>= 0.13.1)
75-
addressable (2.8.5)
76-
public_suffix (>= 2.0.2, < 6.0)
75+
addressable (2.8.8)
76+
public_suffix (>= 2.0.2, < 8.0)
7777
amazing_print (1.5.0)
7878
ast (2.4.3)
7979
base64 (0.3.0)
@@ -208,13 +208,18 @@ GEM
208208
oj (3.16.1)
209209
okcomputer (1.19.1)
210210
benchmark
211-
omniauth (1.9.2)
211+
omniauth (2.1.4)
212212
hashie (>= 3.4.6)
213-
rack (>= 1.6.2, < 3)
214-
omniauth-cas (2.0.0)
215-
addressable (~> 2.3)
216-
nokogiri (~> 1.5)
217-
omniauth (~> 1.2)
213+
logger
214+
rack (>= 2.2.3)
215+
rack-protection
216+
omniauth-cas (3.0.2)
217+
addressable (~> 2.8)
218+
nokogiri (~> 1.12)
219+
omniauth (~> 2.1)
220+
omniauth-rails_csrf_protection (1.0.2)
221+
actionpack (>= 4.2)
222+
omniauth (~> 2.0)
218223
ougai (2.0.0)
219224
oj (~> 3.10)
220225
parallel (1.27.0)
@@ -229,11 +234,14 @@ GEM
229234
psych (5.2.6)
230235
date
231236
stringio
232-
public_suffix (5.0.3)
237+
public_suffix (7.0.0)
233238
puma (5.6.7)
234239
nio4r (~> 2.0)
235-
racc (1.7.1)
236-
rack (2.2.8)
240+
racc (1.8.1)
241+
rack (2.2.21)
242+
rack-protection (3.2.0)
243+
base64 (>= 0.1.0)
244+
rack (~> 2.2, >= 2.2.4)
237245
rack-session (1.0.2)
238246
rack (< 3)
239247
rack-test (2.1.0)
@@ -428,7 +436,8 @@ DEPENDENCIES
428436
listen (>= 3.0)
429437
nokogiri (~> 1.18)
430438
okcomputer (~> 1.19)
431-
omniauth-cas (~> 2.0)
439+
omniauth-cas (~> 3.0)
440+
omniauth-rails_csrf_protection (~> 1.0)
432441
puma (~> 5.3, >= 5.3.1)
433442
rails (~> 8.0.4)
434443
rest-client (~> 2.1)

app/assets/stylesheets/includes/main.scss

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ header {
9797
}
9898

9999
ul {
100-
a {
100+
a, button.calnet_login {
101101
color: black;
102102

103103
&:hover {
@@ -226,7 +226,7 @@ section {
226226
}
227227
}
228228

229-
a {
229+
a, button.calnet_login {
230230
&:hover {
231231
box-shadow: inset 0 -4px 0 $color-anchor-highlight;
232232
}
@@ -257,6 +257,16 @@ section {
257257
}
258258

259259
&.restricted {
260+
form {
261+
button.calnet_login {
262+
box-shadow: inset 0 -4pxq 0 $color-anchor-highlight;
263+
264+
&:hover {
265+
background: $color-anchor-highlight;
266+
border: 1px solid $color-anchor-highlight;
267+
}
268+
}
269+
}
260270
p {
261271
a {
262272
box-shadow: inset 0 -4px 0 $color-anchor-highlight;
@@ -398,3 +408,13 @@ span {
398408

399409
// sass-lint:enable class-name-format
400410
}
411+
412+
button.calnet_login {
413+
background: inherit;
414+
margin: inherit;
415+
border: none;
416+
line-height: inherit;
417+
font-family: inherit;
418+
font-size: inherit;
419+
text-decoration: inherit;
420+
}

app/helpers/application_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def logout_link(text = 'CalNet Logout')
88
end
99

1010
def login_link(text = 'CalNet Login')
11-
link_to(text, login_path(url: request.original_url))
11+
form_tag('/auth/calnet', url: request.original_url, method: 'post', data: { turbo: false }) do
12+
button_tag text, class: 'calnet_login'
13+
end
1214
end
1315

1416
def vpn_link

app/views/player/access_restricted.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<%
33
calnet_only = record&.calnet_only?
44
access_methods = [].tap do |mm|
5-
mm << login_link('log in with CalNet') unless authenticated?
5+
mm << login_link('Log in with CalNet') unless authenticated?
66
mm << vpn_link unless calnet_only || ucb_request?
77
end
88
%>

spec/support/authz_shared_examples.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
expect(page).to have_content(record_id)
2929

3030
show_url = player_url(collection:, record_id:)
31-
expect(page).to have_link(href: login_path(url: show_url))
31+
expect(page).to have_css('button.calnet_login')
3232
end
3333
end
3434

0 commit comments

Comments
 (0)