Skip to content

Commit 90c8efd

Browse files
committed
Rubocop; move enable_auth_bypass into add_middleware block
1 parent d0d3da1 commit 90c8efd

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

lib/rpi_auth/configuration.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Configuration
2020
:user_model
2121

2222
def initialize
23-
@brand = 'raspberrypi-org'
2423
@bypass_auth = false
2524
@response_type = :code
2625
@client_auth_method = :basic

lib/rpi_auth/engine.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Engine < ::Rails::Engine
1313
OmniAuth.config.logger = Rails.logger
1414
end
1515

16-
initializer 'RpiAuth.add_middleware' do |app|
16+
initializer 'RpiAuth.add_middleware' do |app| # rubocop:disable Metrics/BlockLength
1717
next unless RpiAuth.configuration
1818

1919
app.middleware.use OmniAuth::Builder do
@@ -36,18 +36,14 @@ class Engine < ::Rails::Engine
3636
jwks_uri: RpiAuth.configuration.jwks_uri
3737
},
3838
extra_authorize_params: { brand: RpiAuth.configuration.brand },
39-
allow_authorize_params: [ :login_options ],
39+
allow_authorize_params: [:login_options],
4040
origin_param: 'returnTo'
4141
)
4242

4343
OmniAuth.config.on_failure = RpiAuth::AuthController.action(:failure)
44-
end
45-
end
4644

47-
config.after_initialize do
48-
next unless RpiAuth.configuration
49-
50-
RpiAuth.configuration.enable_auth_bypass
45+
RpiAuth.configuration.enable_auth_bypass if RpiAuth.configuration.bypass_auth
46+
end
5147
end
5248
end
5349
end

spec/dummy/config/initializers/rpi_auth.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
config.identity_url = 'http://localhost:3002'
99
config.user_model = 'User'
1010

11+
config.bypass_auth = false
12+
1113
# Profile is running in docker, so we need to set this manually. This
1214
# shouldn't be needed elsewhere, unless you're getting errors saying:
1315
# Invalid ID token: Issuer does not match

spec/rpi_auth/configuration_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
let(:auth_url) { 'https://auth.com:123/' }
77
let(:auth_token_url) { 'https://internal.auth.com:456' }
88

9-
it 'sets a default value for brand' do
10-
expect(configuration.brand).to eq 'raspberrypi-org'
11-
end
12-
139
it 'sets a default value for client_auth_method' do
1410
expect(configuration.client_auth_method).to eq :basic
1511
end

0 commit comments

Comments
 (0)