mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
30 lines
752 B
Ruby
30 lines
752 B
Ruby
# frozen_string_literal:true
|
|
|
|
module Authn
|
|
module Tokens
|
|
class RunnerAuthenticationToken
|
|
def self.prefix?(plaintext)
|
|
plaintext.start_with?(Ci::Runner::CREATED_RUNNER_TOKEN_PREFIX)
|
|
end
|
|
|
|
attr_reader :revocable, :source
|
|
|
|
def initialize(plaintext, source)
|
|
@revocable = ::Ci::Runner.find_by_token(plaintext)
|
|
@source = source
|
|
end
|
|
|
|
def present_with
|
|
::API::Entities::Ci::Runner
|
|
end
|
|
|
|
def revoke!(current_user)
|
|
raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank?
|
|
|
|
service = ::Ci::Runners::ResetAuthenticationTokenService.new(runner: revocable, current_user: current_user)
|
|
service.execute!
|
|
end
|
|
end
|
|
end
|
|
end
|