2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
module Gitlab
|
|
|
|
module Auth
|
|
|
|
module Saml
|
|
|
|
class IdentityLinker < OmniauthIdentityLinkerBase
|
2019-09-30 23:59:55 +05:30
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
|
|
|
UnverifiedRequest = Class.new(StandardError)
|
|
|
|
|
|
|
|
override :link
|
|
|
|
def link
|
|
|
|
raise_unless_request_is_gitlab_initiated! if unlinked?
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def raise_unless_request_is_gitlab_initiated!
|
|
|
|
raise UnverifiedRequest unless valid_gitlab_initiated_request?
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid_gitlab_initiated_request?
|
|
|
|
OriginValidator.new(session).gitlab_initiated?(saml_response)
|
|
|
|
end
|
|
|
|
|
|
|
|
def saml_response
|
|
|
|
oauth.fetch(:extra, {}).fetch(:response_object, {})
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
Gitlab::Auth::Saml::IdentityLinker.prepend_mod
|