Class: Authn::AgnosticTokenIdentifier
- Inherits:
-
Object
- Object
- Authn::AgnosticTokenIdentifier
- 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, ::Authn::Tokens::CiJobToken, ::Authn::Tokens::FeatureFlagsClientToken, ::Authn::Tokens::GitlabSession, ::Authn::Tokens::IncomingEmailToken ].freeze
Class Method Summary collapse
- .name(plaintext) ⇒ Object
- .token?(plaintext) ⇒ Boolean
- .token_for(plaintext, source) ⇒ Object
- .token_type(plaintext) ⇒ Object
Class Method Details
.name(plaintext) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/authn/agnostic_token_identifier.rb', line 33 def self.name(plaintext) type = token_type(plaintext) type = type.new(plaintext, nil).resource_name if type == ::Authn::Tokens::PersonalAccessToken return unless type type.to_s.demodulize.underscore end |
.token?(plaintext) ⇒ Boolean
25 26 27 |
# File 'lib/authn/agnostic_token_identifier.rb', line 25 def self.token?(plaintext) token_type(plaintext).present? end |
.token_for(plaintext, source) ⇒ Object
21 22 23 |
# File 'lib/authn/agnostic_token_identifier.rb', line 21 def self.token_for(plaintext, source) token_type(plaintext)&.new(plaintext, source) end |
.token_type(plaintext) ⇒ Object
29 30 31 |
# File 'lib/authn/agnostic_token_identifier.rb', line 29 def self.token_type(plaintext) TOKEN_TYPES.find { |x| x.prefix?(plaintext) } end |