Class: Authn::Tokens::DeployToken
- Inherits:
-
Object
- Object
- Authn::Tokens::DeployToken
- Defined in:
- lib/authn/tokens/deploy_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) ⇒ DeployToken
constructor
A new instance of DeployToken.
- #present_with ⇒ Object
- #revoke!(current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ DeployToken
Returns a new instance of DeployToken.
12 13 14 15 |
# File 'lib/authn/tokens/deploy_token.rb', line 12 def initialize(plaintext, source) @revocable = ::DeployToken.find_by_token(plaintext) @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
10 11 12 |
# File 'lib/authn/tokens/deploy_token.rb', line 10 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/authn/tokens/deploy_token.rb', line 10 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 |
# File 'lib/authn/tokens/deploy_token.rb', line 6 def self.prefix?(plaintext) plaintext.start_with?(::DeployToken::DEPLOY_TOKEN_PREFIX) end |
Instance Method Details
#present_with ⇒ Object
17 18 19 |
# File 'lib/authn/tokens/deploy_token.rb', line 17 def present_with ::API::Entities::DeployToken end |
#revoke!(current_user) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/authn/tokens/deploy_token.rb', line 21 def revoke!(current_user) raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank? service = ::Groups::DeployTokens::RevokeService.new( revocable.group, current_user, { id: revocable.id } ) service.source = source service.execute end |