Class: StandardId::Provider::RevokedToken
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- StandardId::Provider::RevokedToken
- Defined in:
- app/models/standard_id/provider/revoked_token.rb
Class Method Summary collapse
- .cleanup_expired! ⇒ Object
- .revoke!(jti:, client_id: nil, token_type: nil, expires_at: nil) ⇒ Object
- .revoked?(jti) ⇒ Boolean
Class Method Details
.cleanup_expired! ⇒ Object
26 27 28 |
# File 'app/models/standard_id/provider/revoked_token.rb', line 26 def self.cleanup_expired! where("expires_at <= ?", Time.current).delete_all end |
.revoke!(jti:, client_id: nil, token_type: nil, expires_at: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/standard_id/provider/revoked_token.rb', line 10 def self.revoke!(jti:, client_id: nil, token_type: nil, expires_at: nil) create!( jti: jti, client_id: client_id, token_type: token_type, revoked_at: Time.current, expires_at: expires_at || 1.day.from_now ) rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique # Token already revoked — idempotent end |
.revoked?(jti) ⇒ Boolean
22 23 24 |
# File 'app/models/standard_id/provider/revoked_token.rb', line 22 def self.revoked?(jti) where(jti: jti).exists? end |