Class: Authn::Tokens::ClusterAgentToken
- Inherits:
-
Object
- Object
- Authn::Tokens::ClusterAgentToken
- Defined in:
- lib/authn/tokens/cluster_agent_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) ⇒ ClusterAgentToken
constructor
A new instance of ClusterAgentToken.
- #present_with ⇒ Object
- #revoke!(current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ ClusterAgentToken
Returns a new instance of ClusterAgentToken.
15 16 17 18 19 20 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 15 def initialize(plaintext, source) return unless self.class.prefix?(plaintext) @revocable = ::Clusters::AgentToken.find_by_token(plaintext) @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
13 14 15 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 13 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
13 14 15 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 13 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 9 10 11 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 6 def self.prefix?(plaintext) prefixes = [::Clusters::AgentToken.glagent_prefix, ::Clusters::AgentToken::TOKEN_PREFIX].uniq plaintext.start_with?(*prefixes) end |
Instance Method Details
#present_with ⇒ Object
22 23 24 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 22 def present_with ::API::Entities::Clusters::AgentToken end |
#revoke!(current_user) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/authn/tokens/cluster_agent_token.rb', line 26 def revoke!(current_user) raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank? service = ::Clusters::AgentTokens::RevokeService.new(token: revocable, current_user: current_user) service.execute end |