Class: Vines::Stream::Server::Outbound::Auth
- Inherits:
-
Vines::Stream::State
- Object
- Vines::Stream::State
- Vines::Stream::Server::Outbound::Auth
- Defined in:
- lib/vines/stream/server/outbound/auth.rb
Constant Summary collapse
- REQUIRED =
'required'.freeze
- FEATURES =
'features'.freeze
Constants included from Node
Instance Attribute Summary
Attributes inherited from Vines::Stream::State
Instance Method Summary collapse
-
#initialize(stream, success = AuthDialbackResult) ⇒ Auth
constructor
A new instance of Auth.
- #node(node) ⇒ Object
Methods inherited from Vines::Stream::State
Methods included from Node
body?, namespace, stream?, to_stanza
Methods included from Log
Constructor Details
#initialize(stream, success = AuthDialbackResult) ⇒ Auth
Returns a new instance of Auth.
11 12 13 |
# File 'lib/vines/stream/server/outbound/auth.rb', line 11 def initialize(stream, success=AuthDialbackResult) super end |
Instance Method Details
#node(node) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vines/stream/server/outbound/auth.rb', line 15 def node(node) # We have to remember tls_require for # closing or restarting the stream stream.outbound_tls_required(tls_required?(node)) if stream.dialback_verify_key? @success = Authoritative stream.callback! advance elsif dialback?(node) secret = Kit.auth_token dialback_key = Kit.dialback_key(secret, stream.remote_domain, stream.domain, stream.id) stream.write("<db:result xmlns:db='#{NAMESPACES[:legacy_dialback]}' " \ "from='#{stream.domain}' to='#{stream.remote_domain}'>#{dialback_key}</db:result>") advance stream.router << stream # We need to be discoverable for the dialback connection stream.state.dialback_secret = secret elsif tls?(node) @success = TLSResult stream.write("<starttls xmlns='#{NAMESPACES[:tls]}'/>") advance else raise StreamErrors::NotAuthorized end end |