Make Rubocop happy

parent ed29dcaf
...@@ -21,7 +21,8 @@ module Gitlab ...@@ -21,7 +21,8 @@ module Gitlab
end end
def extract_logout_token def extract_logout_token
LogoutState.new(*state.to_s.split(':', 3)).decode salt, encrypted, return_to = state.to_s.split(':', 3)
LogoutState.new(salt, encrypted, return_to).decode
end end
def get_oauth_state_return_to def get_oauth_state_return_to
...@@ -49,7 +50,12 @@ module Gitlab ...@@ -49,7 +50,12 @@ module Gitlab
private private
class LoginState < Struct.new(:salt, :return_to) class LoginState
def initialize(salt, return_to)
@salt = salt
@return_to = return_to
end
def valid?(hmac) def valid?(hmac)
return false unless salt && return_to return false unless salt && return_to
...@@ -64,14 +70,23 @@ module Gitlab ...@@ -64,14 +70,23 @@ module Gitlab
private private
attr_reader :salt, :return_to
def generate_hmac def generate_hmac
digest = OpenSSL::Digest.new('sha256') digest = OpenSSL::Digest.new('sha256')
key = Gitlab::Application.secrets.secret_key_base + salt key = Gitlab::Application.secrets.secret_key_base + salt
OpenSSL::HMAC.hexdigest(digest, key, return_to) OpenSSL::HMAC.hexdigest(digest, key, return_to)
end end
end end
class LogoutState < Struct.new(:salt, :token, :return_to) class LogoutState
def initialize(salt, token, return_to)
@salt = salt
@token = token
@return_to = return_to
end
def decode def decode
return unless salt && token return unless salt && token
...@@ -95,6 +110,8 @@ module Gitlab ...@@ -95,6 +110,8 @@ module Gitlab
private private
attr_reader :salt, :token, :return_to
def cipher(salt, operation) def cipher(salt, operation)
cipher = OpenSSL::Cipher::AES.new(128, :CBC) cipher = OpenSSL::Cipher::AES.new(128, :CBC)
cipher.__send__(operation) # rubocop:disable GitlabSecurity/PublicSend cipher.__send__(operation) # rubocop:disable GitlabSecurity/PublicSend
...@@ -108,7 +125,11 @@ module Gitlab ...@@ -108,7 +125,11 @@ module Gitlab
end end
end end
class ReturnToLocation < Struct.new(:location) class ReturnToLocation
def initialize(location)
@location = location
end
def full_path def full_path
uri = parse_uri(location) uri = parse_uri(location)
full_path_for_uri(uri) if uri full_path_for_uri(uri) if uri
...@@ -116,6 +137,8 @@ module Gitlab ...@@ -116,6 +137,8 @@ module Gitlab
private private
attr_reader :location
def parse_uri(location) def parse_uri(location)
location && URI.parse(location) location && URI.parse(location)
rescue URI::InvalidURIError rescue URI::InvalidURIError
...@@ -129,11 +152,11 @@ module Gitlab ...@@ -129,11 +152,11 @@ module Gitlab
end end
def oauth_salt def oauth_salt
@salt ||= SecureRandom.hex(8) @oauth_salt ||= SecureRandom.hex(8)
end end
def oauth_client def oauth_client
@client ||= begin @oauth_client ||= begin
::OAuth2::Client.new( ::OAuth2::Client.new(
oauth_app.uid, oauth_app.uid,
oauth_app.secret, oauth_app.secret,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment