Class: SelfSDK::ACL
- Inherits:
-
Object
- Object
- SelfSDK::ACL
- Defined in:
- lib/acl.rb
Overview
Access control list
Instance Method Summary collapse
-
#allow(id) ⇒ Object
Allows incomming messages from the given identity.
-
#deny(id) ⇒ Object
Deny incomming messages from the given identity.
-
#initialize(messaging) ⇒ ACL
constructor
A new instance of ACL.
-
#list ⇒ Object
Lists allowed connections.
Constructor Details
#initialize(messaging) ⇒ ACL
Returns a new instance of ACL.
9 10 11 12 |
# File 'lib/acl.rb', line 9 def initialize(messaging) @messaging = messaging @jwt = @messaging.jwt end |
Instance Method Details
#allow(id) ⇒ Object
Allows incomming messages from the given identity.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/acl.rb', line 25 def allow(id) SelfSDK.logger.info "Allowing connections from #{id}" @messaging.add_acl_rule(@jwt.prepare(jti: SecureRandom.uuid, cid: SecureRandom.uuid, typ: 'acl.permit', iss: @jwt.id, sub: @jwt.id, iat: (SelfSDK::Time.now - 5).strftime('%FT%TZ'), exp: (SelfSDK::Time.now + 60).strftime('%FT%TZ'), acl_source: id, acl_exp: (SelfSDK::Time.now + 360_000).to_datetime.rfc3339)) end |
#deny(id) ⇒ Object
Deny incomming messages from the given identity.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/acl.rb', line 39 def deny(id) SelfSDK.logger.info "Denying connections from #{id}" @messaging.remove_acl_rule(@jwt.prepare(jti: SecureRandom.uuid, cid: SecureRandom.uuid, typ: 'acl.revoke', iss: @jwt.id, sub: @jwt.id, iat: (SelfSDK::Time.now - 5).strftime('%FT%TZ'), exp: (SelfSDK::Time.now + 60).strftime('%FT%TZ'), acl_source: id, acl_exp: (SelfSDK::Time.now + 360_000).to_datetime.rfc3339)) end |