Class: Authn::Tokens::CiJobToken
- Inherits:
-
Object
- Object
- Authn::Tokens::CiJobToken
- Defined in:
- lib/authn/tokens/ci_job_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) ⇒ CiJobToken
constructor
A new instance of CiJobToken.
- #present_with ⇒ Object
- #revoke!(_current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ CiJobToken
Returns a new instance of CiJobToken.
13 14 15 16 17 |
# File 'lib/authn/tokens/ci_job_token.rb', line 13 def initialize(plaintext, source) @revocable = ::Ci::AuthJobFinder.new(token: plaintext).execute @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
11 12 13 |
# File 'lib/authn/tokens/ci_job_token.rb', line 11 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/authn/tokens/ci_job_token.rb', line 11 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 9 |
# File 'lib/authn/tokens/ci_job_token.rb', line 6 def self.prefix?(plaintext) prefixes = [::Ci::JobToken::Jwt.token_prefix, ::Ci::Build::TOKEN_PREFIX].uniq plaintext.start_with?(*prefixes) end |
Instance Method Details
#present_with ⇒ Object
19 20 21 |
# File 'lib/authn/tokens/ci_job_token.rb', line 19 def present_with ::API::Entities::Ci::JobToken end |
#revoke!(_current_user) ⇒ Object
23 24 25 26 27 |
# File 'lib/authn/tokens/ci_job_token.rb', line 23 def revoke!(_current_user) raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank? raise ::Authn::AgnosticTokenIdentifier::UnsupportedTokenError, 'Unsupported token type' end |