2018-10-11 16:12:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
2016-09-19 07:42:10 -04:00
|
|
|
module Auth
|
2016-09-19 08:23:18 -04:00
|
|
|
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
|
2016-09-20 04:24:47 -04:00
|
|
|
def ci?(for_project)
|
|
|
|
type == :ci &&
|
|
|
|
project &&
|
|
|
|
project == for_project
|
2016-09-19 07:42:10 -04:00
|
|
|
end
|
|
|
|
|
2016-09-20 04:24:47 -04:00
|
|
|
def lfs_deploy_token?(for_project)
|
|
|
|
type == :lfs_deploy_token &&
|
2016-11-16 07:31:08 -05:00
|
|
|
actor.try(:has_access_to?, for_project)
|
2016-09-19 10:34:32 -04:00
|
|
|
end
|
|
|
|
|
2016-09-19 07:42:10 -04:00
|
|
|
def success?
|
|
|
|
actor.present? || type == :ci
|
|
|
|
end
|
2017-05-31 09:55:12 -04:00
|
|
|
|
|
|
|
def failed?
|
|
|
|
!success?
|
|
|
|
end
|
2021-07-27 08:10:54 -04:00
|
|
|
|
|
|
|
def auth_user
|
|
|
|
actor.is_a?(User) ? actor : nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def deploy_token
|
|
|
|
actor.is_a?(DeployToken) ? actor : nil
|
|
|
|
end
|
2016-09-19 07:42:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-28 08:09:44 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Gitlab::Auth::Result.prepend_mod_with('Gitlab::Auth::Result')
|