Class: Authn::Tokens::RunnerAuthenticationToken
- Inherits:
-
Object
- Object
- Authn::Tokens::RunnerAuthenticationToken
- Defined in:
- lib/authn/tokens/runner_authentication_token.rb
Instance Attribute Summary collapse
-
#revocable ⇒ Object
readonly
Returns the value of attribute revocable.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(plaintext, source) ⇒ RunnerAuthenticationToken
constructor
A new instance of RunnerAuthenticationToken.
- #present_with ⇒ Object
- #revoke!(current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ RunnerAuthenticationToken
Returns a new instance of RunnerAuthenticationToken.
17 18 19 20 21 22 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 17 def initialize(plaintext, source) return unless self.class.prefix?(plaintext) @revocable = ::Ci::Runner.find_by_token(plaintext) @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
15 16 17 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 15 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
15 16 17 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 15 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 9 10 11 12 13 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 6 def self.prefix?(plaintext) prefixes = [ ::Ci::Runner.created_runner_prefix, ::Ci::Runner::CREATED_RUNNER_TOKEN_PREFIX ] plaintext.start_with?(*prefixes) end |
Instance Method Details
#present_with ⇒ Object
24 25 26 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 24 def present_with ::API::Entities::Ci::Runner end |
#revoke!(current_user) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/authn/tokens/runner_authentication_token.rb', line 28 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 |