Class: Authn::AgnosticTokenIdentifier

Inherits:
Object
  • Object
show all
Defined in:
lib/authn/agnostic_token_identifier.rb

Constant Summary collapse

NotFoundError =
Class.new(StandardError)
UnsupportedTokenError =
Class.new(StandardError)
TOKEN_TYPES =
[
  ::Authn::Tokens::DeployToken,
  ::Authn::Tokens::FeedToken,
  ::Authn::Tokens::PersonalAccessToken,
  ::Authn::Tokens::OauthApplicationSecret,
  ::Authn::Tokens::ClusterAgentToken,
  ::Authn::Tokens::RunnerAuthenticationToken,
  ::Authn::Tokens::CiTriggerToken
].freeze

Class Method Summary collapse

Class Method Details

.token_for(plaintext, source) ⇒ Object



17
18
19
# File 'lib/authn/agnostic_token_identifier.rb', line 17

def self.token_for(plaintext, source)
  TOKEN_TYPES.find { |x| x.prefix?(plaintext) }&.new(plaintext, source)
end