Skip to content

Commit 92eff2d

Browse files
committed
Extract openid_connect_options
So that I can avoid disabling the Metrics/BlockLength RuboCop rule.
1 parent 966bef4 commit 92eff2d

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

lib/rpi_auth/engine.rb

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,37 @@ class Engine < ::Rails::Engine
2323
initializer 'RpiAuth.add_middleware' do |app| # rubocop:disable Metrics/BlockLength
2424
next unless RpiAuth.configuration
2525

26-
# rubocop:disable Metrics/BlockLength
26+
openid_connect_options = {
27+
name: :rpi,
28+
setup: RpiAuth.configuration.setup,
29+
issuer: RpiAuth.configuration.issuer,
30+
scope: RpiAuth.configuration.scope,
31+
callback_path: CALLBACK_PATH,
32+
response_type: RpiAuth.configuration.response_type,
33+
client_auth_method: RpiAuth.configuration.client_auth_method,
34+
client_options: {
35+
identifier: RpiAuth.configuration.auth_client_id,
36+
secret: RpiAuth.configuration.auth_client_secret,
37+
scheme: RpiAuth.configuration.token_endpoint.scheme,
38+
host: RpiAuth.configuration.token_endpoint.host,
39+
port: RpiAuth.configuration.token_endpoint.port,
40+
authorization_endpoint: RpiAuth.configuration.authorization_endpoint,
41+
token_endpoint: RpiAuth.configuration.token_endpoint,
42+
jwks_uri: RpiAuth.configuration.jwks_uri,
43+
redirect_uri: URI.join(RpiAuth.configuration.host_url, CALLBACK_PATH)
44+
},
45+
extra_authorize_params: { brand: RpiAuth.configuration.brand },
46+
allow_authorize_params: [:login_options],
47+
origin_param: 'returnTo'
48+
}
49+
2750
app.middleware.use OmniAuth::Builder do
28-
provider(
29-
:openid_connect,
30-
name: :rpi,
31-
setup: RpiAuth.configuration.setup,
32-
issuer: RpiAuth.configuration.issuer,
33-
scope: RpiAuth.configuration.scope,
34-
callback_path: CALLBACK_PATH,
35-
response_type: RpiAuth.configuration.response_type,
36-
client_auth_method: RpiAuth.configuration.client_auth_method,
37-
client_options: {
38-
identifier: RpiAuth.configuration.auth_client_id,
39-
secret: RpiAuth.configuration.auth_client_secret,
40-
scheme: RpiAuth.configuration.token_endpoint.scheme,
41-
host: RpiAuth.configuration.token_endpoint.host,
42-
port: RpiAuth.configuration.token_endpoint.port,
43-
authorization_endpoint: RpiAuth.configuration.authorization_endpoint,
44-
token_endpoint: RpiAuth.configuration.token_endpoint,
45-
jwks_uri: RpiAuth.configuration.jwks_uri,
46-
redirect_uri: URI.join(RpiAuth.configuration.host_url, CALLBACK_PATH)
47-
},
48-
extra_authorize_params: { brand: RpiAuth.configuration.brand },
49-
allow_authorize_params: [:login_options],
50-
origin_param: 'returnTo'
51-
)
51+
provider(:openid_connect, openid_connect_options)
5252

5353
OmniAuth.config.on_failure = RpiAuth::AuthController.action(:failure)
5454

5555
RpiAuth.configuration.enable_auth_bypass if RpiAuth.configuration.bypass_auth
5656
end
57-
# rubocop:enable Metrics/BlockLength
5857
end
5958
end
6059
end

0 commit comments

Comments
 (0)