Class: Authn::Tokens::ClusterAgentToken

Inherits:
Object
  • Object
show all
Defined in:
lib/authn/tokens/cluster_agent_token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plaintext, source) ⇒ ClusterAgentToken

Returns a new instance of ClusterAgentToken.



12
13
14
15
# File 'lib/authn/tokens/cluster_agent_token.rb', line 12

def initialize(plaintext, source)
  @revocable = ::Clusters::AgentToken.find_by_token(plaintext)
  @source = source
end

Instance Attribute Details

#revocableObject (readonly)

Returns the value of attribute revocable.



10
11
12
# File 'lib/authn/tokens/cluster_agent_token.rb', line 10

def revocable
  @revocable
end

#sourceObject (readonly)

Returns the value of attribute source.



10
11
12
# File 'lib/authn/tokens/cluster_agent_token.rb', line 10

def source
  @source
end

Class Method Details

.prefix?(plaintext) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/authn/tokens/cluster_agent_token.rb', line 6

def self.prefix?(plaintext)
  plaintext.start_with?(::Clusters::AgentToken::TOKEN_PREFIX)
end

Instance Method Details

#present_withObject



17
18
19
# File 'lib/authn/tokens/cluster_agent_token.rb', line 17

def present_with
  ::API::Entities::Clusters::AgentToken
end

#revoke!(_current_user) ⇒ Object



21
22
23
24
25
# File 'lib/authn/tokens/cluster_agent_token.rb', line 21

def revoke!(_current_user)
  raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank?

  raise ::Authn::AgnosticTokenIdentifier::UnsupportedTokenError, 'Unsupported token type'
end