Class: Ace::Git::Secrets::Molecules::TokenRevoker
- Inherits:
-
Object
- Object
- Ace::Git::Secrets::Molecules::TokenRevoker
- Defined in:
- lib/ace/git/secrets/molecules/token_revoker.rb
Overview
Orchestrates token revocation across multiple services Routes tokens to appropriate service handlers
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#initialize(api_client: nil) ⇒ TokenRevoker
constructor
A new instance of TokenRevoker.
-
#revocation_instructions(token) ⇒ Hash
Get revocation instructions for a token.
-
#revoke_all(tokens, services: nil) ⇒ Array<Models::RevocationResult>
Revoke multiple tokens.
-
#revoke_token(token) ⇒ Models::RevocationResult
Revoke a single token.
Constructor Details
#initialize(api_client: nil) ⇒ TokenRevoker
Returns a new instance of TokenRevoker.
13 14 15 |
# File 'lib/ace/git/secrets/molecules/token_revoker.rb', line 13 def initialize(api_client: nil) @api_client = api_client || Atoms::ServiceApiClient.new end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
10 11 12 |
# File 'lib/ace/git/secrets/molecules/token_revoker.rb', line 10 def api_client @api_client end |
Instance Method Details
#revocation_instructions(token) ⇒ Hash
Get revocation instructions for a token
54 55 56 57 |
# File 'lib/ace/git/secrets/molecules/token_revoker.rb', line 54 def revocation_instructions(token) service = token.revocation_service api_client.build_revocation_request(service, token.raw_value) end |
#revoke_all(tokens, services: nil) ⇒ Array<Models::RevocationResult>
Revoke multiple tokens
21 22 23 24 25 26 27 28 |
# File 'lib/ace/git/secrets/molecules/token_revoker.rb', line 21 def revoke_all(tokens, services: nil) tokens.map do |token| next unless token.revocable? next if services && !services.include?(token.revocation_service) revoke_token(token) end.compact end |
#revoke_token(token) ⇒ Models::RevocationResult
Revoke a single token
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ace/git/secrets/molecules/token_revoker.rb', line 33 def revoke_token(token) service = token.revocation_service unless service return Models::RevocationResult.unsupported(token: token) end case service when "github" revoke_github(token) when "anthropic", "openai", "aws" # These services don't have public revocation APIs manual_revocation_result(token, service) else Models::RevocationResult.unsupported(token: token, service: service) end end |