Class: Insika::Commands::RevokeToken
- Inherits:
-
Object
- Object
- Insika::Commands::RevokeToken
- Defined in:
- lib/insika/commands/revoke_token.rb
Overview
WS1: revokes ONE token by id. The edge resolves tokens by hash, so the plaintext is not needed to kill a credential. Idempotent: revoking an already-revoked or unknown id -> { revoked: false }, never an error. -> { id:, revoked: bool }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(token_store:, event_stream:) ⇒ RevokeToken
constructor
A new instance of RevokeToken.
Constructor Details
#initialize(token_store:, event_stream:) ⇒ RevokeToken
Returns a new instance of RevokeToken.
10 11 12 13 |
# File 'lib/insika/commands/revoke_token.rb', line 10 def initialize(token_store:, event_stream:) @token_store = token_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/insika/commands/revoke_token.rb', line 15 def call(command) raise Insika::ValidationError, "token commands are operator-only" if command.[:tenant] id = Insika::Coercion.presence( command.payload[:token_id] || command.payload["token_id"] ) raise Insika::ValidationError, "token_id is required" if id.nil? revoked = @token_store.revoke(id) emit(id, revoked) { id: id, revoked: revoked } end |