Skip to content

Commit 55d0011

Browse files
committed
Upgrade omniauth-github to 2.1.4
1 parent 65e71f5 commit 55d0011

File tree

11 files changed

+45
-16
lines changed

11 files changed

+45
-16
lines changed

Gemfile.lock

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PATH
1313
jquery-rails (~> 4.4)
1414
lodash-rails (~> 4.17)
1515
octokit (~> 5.6.0)
16-
omniauth-github (~> 1.4)
16+
omniauth-github (~> 2.0)
1717
paquito
1818
pubsubstub (~> 0.2)
1919
rails (~> 8.0.1)
@@ -246,15 +246,17 @@ GEM
246246
octokit (5.6.1)
247247
faraday (>= 1, < 3)
248248
sawyer (~> 0.9)
249-
omniauth (1.9.2)
249+
omniauth (2.1.4)
250250
hashie (>= 3.4.6)
251-
rack (>= 1.6.2, < 3)
252-
omniauth-github (1.4.0)
253-
omniauth (~> 1.5)
254-
omniauth-oauth2 (>= 1.4.0, < 2.0)
255-
omniauth-oauth2 (1.7.3)
251+
logger
252+
rack (>= 2.2.3)
253+
rack-protection
254+
omniauth-github (2.0.1)
255+
omniauth (~> 2.0)
256+
omniauth-oauth2 (~> 1.8)
257+
omniauth-oauth2 (1.8.0)
256258
oauth2 (>= 1.4, < 3)
257-
omniauth (>= 1.9, < 3)
259+
omniauth (~> 2.0)
258260
ostruct (0.6.2)
259261
paquito (0.10.0)
260262
msgpack (>= 1.5.2)
@@ -276,6 +278,9 @@ GEM
276278
redis (~> 4.0)
277279
racc (1.8.1)
278280
rack (2.2.17)
281+
rack-protection (3.2.0)
282+
base64 (>= 0.1.0)
283+
rack (~> 2.2, >= 2.2.4)
279284
rack-session (1.0.2)
280285
rack (< 3)
281286
rack-test (2.2.0)

app/controllers/concerns/shipit/authentication.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def force_github_authentication
2121
if current_user.logged_in? && current_user.requires_fresh_login?
2222
Rails.logger.warn("User #{current_user.id} requires a fresh login, logging out...")
2323
reset_session
24-
redirect_to(Shipit::Engine.routes.url_helpers.github_authentication_path(origin: request.original_url))
24+
redirect_to(Shipit::Engine.routes.url_helpers.github_authentication_login_path(origin: request.original_url))
2525
elsif Shipit.authentication_disabled? || current_user.logged_in?
2626
unless current_user.authorized?
2727
team_handles = Shipit.github_teams.map(&:handle)
2828
team_list = team_handles.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')
2929
render(plain: "You must be a member of #{team_list} to access this application.", status: :forbidden)
3030
end
3131
else
32-
redirect_to(Shipit::Engine.routes.url_helpers.github_authentication_path(origin: request.original_url))
32+
redirect_to(Shipit::Engine.routes.url_helpers.github_authentication_login_path(origin: request.original_url))
3333
end
3434
end
3535

app/controllers/shipit/github_authentication_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module Shipit
44
class GithubAuthenticationController < ActionController::Base
55
include Shipit::Engine.routes.url_helpers
66

7+
layout 'shipit', only: 'login'
8+
79
def callback
810
return_url = request.env['omniauth.origin'] || root_path
911
auth = request.env['omniauth.auth']
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<% content_for :page_title do %>
2+
<h1>Login</h1>
3+
<% end %>
4+
5+
<div class="wrapper">
6+
<section>
7+
<%= form_with url: github_authentication_path, method: :post do |form| %>
8+
<%= form.hidden_field :origin, value: params[:origin] %>
9+
<div class="field-wrapper">
10+
<%= form.submit "Login with GitHub", class: 'btn primary' %>
11+
</div>
12+
<% end %>
13+
</section>
14+
</div>

config/routes.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
end
6969

7070
scope '/github/auth/github', as: :github_authentication, controller: :github_authentication do
71-
get '/', action: :request
71+
get :login
72+
post '/', action: :request
7273
post :callback
7374
get :callback
7475
get :logout

lib/shipit/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Engine < ::Rails::Engine
4545
ActiveModel::Serializer.include(Engine.routes.url_helpers)
4646

4747
if Shipit.github.oauth?
48+
OmniAuth::AuthenticityTokenProtection.default_options(key: "_csrf_token", authenticity_param: "authenticity_token")
4849
OmniAuth::Strategies::GitHub.configure(path_prefix: '/github/auth')
4950
app.middleware.use(OmniAuth::Builder) do
5051
provider(:github, *Shipit.github.oauth_config)

shipit-engine.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
3131
s.add_dependency('jquery-rails', '~> 4.4')
3232
s.add_dependency('lodash-rails', '~> 4.17')
3333
s.add_dependency('octokit', '~> 5.6.0')
34-
s.add_dependency('omniauth-github', '~> 1.4')
34+
s.add_dependency('omniauth-github', '~> 2.0')
3535
s.add_dependency('paquito')
3636
s.add_dependency('pubsubstub', '~> 0.2')
3737
s.add_dependency('rails', '~> 8.0.1')

test/controllers/api_clients_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ApiClientsControllerTest < ActionController::TestCase
1313
test "GitHub authentication is mandatory" do
1414
session[:user_id] = nil
1515
get :index
16-
assert_redirected_to '/github/auth/github?origin=http%3A%2F%2Ftest.host%2Fapi_clients'
16+
assert_redirected_to '/github/auth/github/login?origin=http%3A%2F%2Ftest.host%2Fapi_clients'
1717
end
1818

1919
test "current_user must be a member of at least a Shipit.github_teams" do

test/controllers/github_authentication_controller_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
module Shipit
66
class GithubAuthenticationControllerTest < ActionController::TestCase
7+
test ":login can render a page to start the OAuth Flow" do
8+
get :login
9+
10+
assert_response :ok
11+
end
12+
713
test ":callback can sign in to github" do
814
auth = OmniAuth::AuthHash.new(
915
credentials: OmniAuth::AuthHash.new(

test/controllers/repositories_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RepositoriesControllerTest < ActionController::TestCase
1313
test "GitHub authentication is mandatory" do
1414
session[:user_id] = nil
1515
get :index
16-
assert_redirected_to '/github/auth/github?origin=http%3A%2F%2Ftest.host%2Frepositories'
16+
assert_redirected_to '/github/auth/github/login?origin=http%3A%2F%2Ftest.host%2Frepositories'
1717
end
1818

1919
test "current_user must be a member of at least a Shipit.github_teams" do

0 commit comments

Comments
 (0)