Class: Faye::Authentication::ServerExtension
- Inherits:
-
Object
- Object
- Faye::Authentication::ServerExtension
- Includes:
- Logging
- Defined in:
- lib/faye/authentication/server_extension.rb
Instance Method Summary collapse
- #incoming(message, callback) ⇒ Object
-
#initialize(secret, options = {}) ⇒ ServerExtension
constructor
A new instance of ServerExtension.
Constructor Details
#initialize(secret, options = {}) ⇒ ServerExtension
Returns a new instance of ServerExtension.
8 9 10 11 |
# File 'lib/faye/authentication/server_extension.rb', line 8 def initialize(secret, = {}) @options = @secret = secret.to_s end |
Instance Method Details
#incoming(message, callback) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/faye/authentication/server_extension.rb', line 13 def incoming(, callback) if Faye::Authentication.authentication_required?(, @options) begin Faye::Authentication.validate(['signature'], ['subscription'] || ['channel'], ['clientId'], @secret) debug("Authentication sucessful") rescue AuthError => exception ['error'] = case exception when ExpiredError then 'Expired signature' when PayloadError then 'Required argument not signed' else 'Invalid signature' end debug("Authentication failed: #{['error']}") end .delete('signature') end callback.call() end |