Class: Authn::Tokens::CiTriggerToken
- Inherits:
-
Object
- Object
- Authn::Tokens::CiTriggerToken
- Defined in:
- lib/authn/tokens/ci_trigger_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) ⇒ CiTriggerToken
constructor
A new instance of CiTriggerToken.
- #present_with ⇒ Object
- #revoke!(current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ CiTriggerToken
Returns a new instance of CiTriggerToken.
14 15 16 17 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 14 def initialize(plaintext, source) @revocable = ::Ci::Trigger.find_by_token(plaintext) @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
12 13 14 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 12 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 12 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 9 10 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 6 def self.prefix?(plaintext) prefixes = [::Ci::Trigger::TRIGGER_TOKEN_PREFIX, ::Ci::Trigger.prefix_for_trigger_token].uniq plaintext.start_with?(*prefixes) end |
Instance Method Details
#present_with ⇒ Object
19 20 21 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 19 def present_with ::API::Entities::Trigger end |
#revoke!(current_user) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/authn/tokens/ci_trigger_token.rb', line 23 def revoke!(current_user) raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank? unless Feature.enabled?(:token_api_expire_pipeline_triggers, revocable.project) raise ::Authn::AgnosticTokenIdentifier::UnsupportedTokenError, 'Unsupported token type' end ::Ci::PipelineTriggers::ExpireService.new(user: current_user, trigger: revocable).execute end |