Module autobahn.wamp¶
WAMP Interfaces¶
-
class
autobahn.wamp.interfaces.IObjectSerializer[source]¶ Raw Python object serialization and deserialization. Object serializers are used by classes implementing WAMP serializers, that is instances of
autobahn.wamp.interfaces.ISerializer.-
BINARY¶ Flag (read-only) to indicate if serializer requires a binary clean transport or if UTF8 transparency is sufficient.
-
-
class
autobahn.wamp.interfaces.ISerializer[source]¶ WAMP message serialization and deserialization.
-
MESSAGE_TYPE_MAP¶ Mapping of WAMP message type codes to WAMP message classes.
-
SERIALIZER_ID¶ The WAMP serialization format ID.
-
serialize(message)[source]¶ Serializes a WAMP message to bytes for sending over a transport.
Parameters: message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message to be serialized.Returns: A pair (payload, isBinary).Return type: tuple
-
-
class
autobahn.wamp.interfaces.IMessage[source]¶ -
MESSAGE_TYPE¶ WAMP message type code.
-
serialize(serializer)[source]¶ Serialize this object into a wire level bytes representation and cache the resulting bytes. If the cache already contains an entry for the given serializer, return the cached representation directly.
Parameters: serializer (object implementing autobahn.wamp.interfaces.ISerializer) – The wire level serializer to use.Returns: The serialized bytes. Return type: bytes
-
-
class
autobahn.wamp.interfaces.ITransport[source]¶ A WAMP transport is a bidirectional, full-duplex, reliable, ordered, message-based channel.
-
send(message)[source]¶ Send a WAMP message over the transport to the peer. If the transport is not open, this raises
autobahn.wamp.exception.TransportLost. Returns a deferred/future when the message has been processed and more messages may be sent. When send() is called while a previous deferred/future has not yet fired, the send will fail immediately.Parameters: message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message to send over the transport.Returns: obj – A Deferred/Future
-
isOpen()[source]¶ Check if the transport is open for messaging.
Returns: True, if the transport is open.Return type: bool
-
close()[source]¶ Close the transport regularly. The transport will perform any closing handshake if applicable. This should be used for any application initiated closing.
-
abort()[source]¶ Abort the transport abruptly. The transport will be destroyed as fast as possible, and without playing nice to the peer. This should only be used in case of fatal errors, protocol violations or possible detected attacks.
-
get_channel_id()[source]¶ Return the unique channel ID of the underlying transport. This is used to mitigate credential forwarding man-in-the-middle attacks when running application level authentication (eg WAMP-cryptosign) which are decoupled from the underlying transport.
The channel ID is only available when running over TLS (either WAMP-WebSocket or WAMP-RawSocket). It is not available for non-TLS transports (plain TCP or Unix domain sockets). It is also not available for WAMP-over-HTTP/Longpoll. Further, it is currently unimplemented for asyncio (only works on Twisted).
The channel ID is computed as follows:
- for a client, the SHA256 over the “TLS Finished” message sent by the client to the server is returned.
- for a server, the SHA256 over the “TLS Finished” message the server expected the client to send
Note: this is similar to tls-unique as described in RFC5929, but instead of returning the raw “TLS Finished” message, it returns a SHA256 over such a message. The reason is that we use the channel ID mainly with WAMP-cryptosign, which is based on Ed25519, where keys are always 32 bytes. And having a channel ID which is always 32 bytes (independent of the TLS ciphers/hashfuns in use) allows use to easily XOR channel IDs with Ed25519 keys and WAMP-cryptosign challenges.
WARNING: For safe use of this (that is, for safely binding app level authentication to the underlying transport), you MUST use TLS, and you SHOULD deactivate both TLS session renegotiation and TLS session resumption.
References:
Returns: The channel ID (if available) of the underlying WAMP transport. The channel ID is a 32 bytes value. Return type: binary or None
-
-
class
autobahn.wamp.interfaces.ITransportHandler[source]¶ -
transport¶ When the transport this handler is attached to is currently open, this property can be read from. The property should be considered read-only. When the transport is gone, this property is set to None.
-
onOpen(transport)[source]¶ Callback fired when transport is open. May run asynchronously. The transport is considered running and is_open() would return true, as soon as this callback has completed successfully.
Parameters: transport (object implementing autobahn.wamp.interfaces.ITransport) – The WAMP transport.
-
onMessage(message)[source]¶ Callback fired when a WAMP message was received. May run asynchronously. The callback should return or fire the returned deferred/future when it’s done processing the message. In particular, an implementation of this callback must not access the message afterwards.
Parameters: message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message received.
-
-
class
autobahn.wamp.interfaces.ISession(config=None)[source]¶ Interface for WAMP sessions.
Parameters: config (instance of autobahn.wamp.types.ComponentConfig.) – Configuration for session.-
onUserError(fail, msg)[source]¶ This is called when we try to fire a callback, but get an exception from user code – for example, a registered publish callback or a registered method. By default, this prints the current stack-trace and then error-message to stdout.
ApplicationSession-derived objects may override this to provide logging if they prefer. The Twisted implemention does this. (See
autobahn.twisted.wamp.ApplicationSession)Parameters: - fail (instance implementing txaio.IFailedFuture) – The failure that occurred.
- msg (str) – an informative message from the library. It is suggested you log this immediately after the exception.
-
onConnect()[source]¶ Callback fired when the transport this session will run over has been established.
-
join(realm, authmethods=None, authid=None, authrole=None, authextra=None, resumable=None, resume_session=None, resume_token=None)[source]¶ Attach the session to the given realm. A session is open as soon as it is attached to a realm.
-
onChallenge(challenge)[source]¶ Callback fired when the peer demands authentication.
May return a Deferred/Future.
Parameters: challenge (Instance of autobahn.wamp.types.Challenge.) – The authentication challenge.
-
onWelcome(welcome_msg)[source]¶ Callback fired after the peer has successfully authenticated. If this returns anything other than None/False, the session is aborted and the return value is used as an error message.
May return a Deferred/Future.
Parameters: welcome_msg – The WELCOME message received from the server Returns: None, or an error message
-
onJoin(details)[source]¶ Callback fired when WAMP session has been established.
May return a Deferred/Future.
Parameters: details (Instance of autobahn.wamp.types.SessionDetails.) – Session information.
-
leave(reason=None, message=None)[source]¶ Actively close this WAMP session.
Parameters: Returns: may return a Future/Deferred that fires when we’ve disconnected
-
onLeave(details)[source]¶ Callback fired when WAMP session has is closed
Parameters: details (Instance of autobahn.wamp.types.CloseDetails.) – Close information.
-
set_payload_codec(payload_codec)[source]¶ Set a payload codec on the session. To remove a previously set payload codec, set the codec to
None.Payload codecs are used with WAMP payload transparency mode.
Parameters: payload_codec (object implementing autobahn.wamp.interfaces.IPayloadCodecorNone) – The payload codec that should process application payload of the given encoding.
-
get_payload_codec()[source]¶ Get the current payload codec (if any) for the session.
Payload codecs are used with WAMP payload transparency mode.
Returns: The current payload codec or Noneif no codec is active.Return type: object implementing autobahn.wamp.interfaces.IPayloadCodecorNone
-
define(exception, error=None)[source]¶ Defines an exception for a WAMP error in the context of this WAMP session.
Parameters: - exception (A class that derives of
Exception.) – The exception class to define an error mapping for. - error (str) – The URI (or URI pattern) the exception class should be mapped for.
Iff the
exceptionclass is decorated, this must beNone.
- exception (A class that derives of
-
call(procedure, *args, **kwargs)[source]¶ Call a remote procedure.
This will return a Deferred/Future, that when resolved, provides the actual result returned by the called remote procedure.
- If the result is a single positional return value, it’ll be returned “as-is”.
- If the result contains multiple positional return values or keyword return values,
the result is wrapped in an instance of
autobahn.wamp.types.CallResult. - If the call fails, the returned Deferred/Future will be rejected with an instance
of
autobahn.wamp.exception.ApplicationError.
If
kwargscontains anoptionskeyword argument that is an instance ofautobahn.wamp.types.CallOptions, this will provide specific options for the call to perform.When the Caller and Dealer implementations support canceling of calls, the call may be canceled by canceling the returned Deferred/Future.
Parameters: Returns: A Deferred/Future for the call result -
Return type: instance of twisted.internet.defer.Deferred /
asyncio.Future
-
register(endpoint, procedure=None, options=None, prefix=None)[source]¶ Register a procedure for remote calling.
When
endpointis a callable (function, method or object that implements__call__), thenproceduremust be provided and an instance of twisted.internet.defer.Deferred (when running on Twisted) or an instance ofasyncio.Future(when running on asyncio) is returned.- If the registration succeeds the returned Deferred/Future will resolve to
an object that implements
autobahn.wamp.interfaces.IRegistration. - If the registration fails the returned Deferred/Future will reject with an
instance of
autobahn.wamp.exception.ApplicationError.
When
endpointis an object, then each of the object’s methods that is decorated withautobahn.wamp.register()is automatically registered and a (single) DeferredList or Future is returned that gathers all individual underlying Deferreds/Futures.Parameters: - endpoint (callable or object) – The endpoint called under the procedure.
- procedure (unicode) – When
endpointis a callable, the URI (or URI pattern) of the procedure to register for. Whenendpointis an object, the argument is ignored (and should beNone). - options (instance of
autobahn.wamp.types.RegisterOptions.) – Options for registering. - prefix (str) – if not None, this specifies a prefix to prepend to all URIs registered for this class. So if there was an @wamp.register(‘method_foo’) on a method and prefix=’com.something.’ then a method ‘com.something.method_foo’ would ultimately be registered.
Returns: A registration or a list of registrations (or errors)
Return type: instance(s) of twisted.internet.defer.Deferred /
asyncio.Future- If the registration succeeds the returned Deferred/Future will resolve to
an object that implements
-
publish(topic, *args, **kwargs)[source]¶ Publish an event to a topic.
If
kwargscontains anoptionskeyword argument that is an instance ofautobahn.wamp.types.PublishOptions, this will provide specific options for the publish to perform.Note
By default, publications are non-acknowledged and the publication can fail silently, e.g. because the session is not authorized to publish to the topic.
When publication acknowledgement is requested via
options.acknowledge == True, this function returns a Deferred/Future:- If the publication succeeds the Deferred/Future will resolve to an object
that implements
autobahn.wamp.interfaces.IPublication. - If the publication fails the Deferred/Future will reject with an instance
of
autobahn.wamp.exception.ApplicationError.
Parameters: Returns: Acknowledgement for acknowledge publications - otherwise nothing.
Return type: Noneor instance of twisted.internet.defer.Deferred /asyncio.Future- If the publication succeeds the Deferred/Future will resolve to an object
that implements
-
subscribe(handler, topic=None, options=None)[source]¶ Subscribe to a topic for receiving events.
When
handleris a callable (function, method or object that implements__call__), then topic must be provided and an instance of twisted.internet.defer.Deferred (when running on Twisted) or an instance ofasyncio.Future(when running on asyncio) is returned.- If the subscription succeeds the Deferred/Future will resolve to an object
that implements
autobahn.wamp.interfaces.ISubscription. - If the subscription fails the Deferred/Future will reject with an instance
of
autobahn.wamp.exception.ApplicationError.
When
handleris an object, then each of the object’s methods that is decorated withautobahn.wamp.subscribe()is automatically subscribed as event handlers, and a list of Deferreds/Futures is returned that each resolves or rejects as above.Parameters: - handler (callable or object) – The event handler to receive events.
- topic (unicode) – When
handleris a callable, the URI (or URI pattern) of the topic to subscribe to. Whenhandleris an object, this value is ignored (and should beNone). - options (An instance of
autobahn.wamp.types.SubscribeOptions.) – Options for subscribing.
Returns: A single Deferred/Future or a list of such objects
Return type: instance(s) of twisted.internet.defer.Deferred /
asyncio.Future- If the subscription succeeds the Deferred/Future will resolve to an object
that implements
-
-
class
autobahn.wamp.interfaces.IPayloadCodec[source]¶ WAMP payload codecs are used with WAMP payload transparency mode.
In payload transparency mode, application payloads are transmitted “raw”, as binary strings, without any processing at the WAMP router.
Payload transparency can be used eg for these use cases:
- end-to-end encryption of application payloads (WAMP-cryptobox)
- using serializers with custom user types, where the serializer and the serializer implementation has native support for serializing custom types (such as CBOR)
- transmitting MQTT payloads within WAMP, when the WAMP router is providing a MQTT-WAMP bridge
-
encode(is_originating, uri, args=None, kwargs=None)[source]¶ Encodes application payload.
Parameters: - is_originating (bool) – Flag indicating whether the encoding is to be done from an originator (a caller or publisher).
- uri (str) – The WAMP URI associated with the WAMP message for which the payload is to be encoded (eg topic or procedure).
- args (list or None) – Positional application payload.
- kwargs (dict or None) – Keyword-based application payload.
Returns: The encoded application payload or None to signal no encoding should be used.
Return type: instance of
autobahn.wamp.types.EncodedPayload
-
decode(is_originating, uri, encoded_payload)[source]¶ Decode application payload.
Parameters: - is_originating (bool) – Flag indicating whether the encoding is to be done from an originator (a caller or publisher).
- uri (str) – The WAMP URI associated with the WAMP message for which the payload is to be encoded (eg topic or procedure).
- payload (instance of
autobahn.wamp.types.EncodedPayload) – The encoded application payload to be decoded.
Returns: A tuple with the decoded positional and keyword-based application payload:
(uri, args, kwargs)Return type:
WAMP Types¶
-
class
autobahn.wamp.types.ComponentConfig(realm=None, extra=None, keyring=None, controller=None, shared=None)[source]¶ WAMP application component configuration. An instance of this class is provided to the constructor of
autobahn.wamp.protocol.ApplicationSession.Parameters: - realm (str) – The realm the session would like to join or
Noneto let the router auto-decide the realm (if the router is configured and allowing to do so). - extra (arbitrary) – Optional user-supplied object with extra configuration. This can be any object you like, and is accessible in your ApplicationSession subclass via self.config.extra. dict is a good default choice. Important: if the component is to be hosted by Crossbar.io, the supplied value must be JSON serializable.
- keyring (obj implementing IKeyRing or None) – A mapper from WAMP URIs to “from”/”to” Ed25519 keys. When using WAMP end-to-end encryption, application payload is encrypted using a symmetric message key, which in turn is encrypted using the “to” URI (topic being published to or procedure being called) public key and the “from” URI private key. In both cases, the key for the longest matching URI is used.
- controller (instance of ApplicationSession or None) – A WAMP ApplicationSession instance that holds a session to a controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time.
- shared (dict or None) – A dict object to exchange user information or hold user objects shared between components run under the same controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time. Use with caution, as using this feature can introduce coupling between components. A valid use case would be to hold a shared database connection pool.
- realm (str) – The realm the session would like to join or
-
class
autobahn.wamp.types.Accept(realm=None, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None)[source]¶ Information to accept a
HELLO.Parameters: - realm (str) – The realm the client is joined to.
- authid (str) – The authentication ID the client is assigned, e.g.
"joe"or"joe@example.com". - authrole (str) – The authentication role the client is assigned, e.g.
"anonymous","user"or"com.myapp.user". - authmethod (str) – The authentication method that was used to authenticate the client, e.g.
"cookie"or"wampcra". - authprovider (str) – The authentication provider that was used to authenticate the client, e.g.
"mozilla-persona". - authextra (dict) – Application-specific authextra to be forwarded to the client in WELCOME.details.authextra.
-
class
autobahn.wamp.types.Deny(reason=u'wamp.error.not_authorized', message=None)[source]¶ Information to deny a
HELLO.Parameters:
-
class
autobahn.wamp.types.Challenge(method, extra=None)[source]¶ Information to challenge the client upon
HELLO.Parameters:
-
class
autobahn.wamp.types.HelloDetails(realm=None, authmethods=None, authid=None, authrole=None, authextra=None, session_roles=None, pending_session=None, resumable=None, resume_session=None, resume_token=None)[source]¶ Provides details of a WAMP session while still attaching.
Parameters: - realm (str or None) – The realm the client wants to join.
- authmethods (list of str or None) – The authentication methods the client is willing to perform.
- authid (str or None) – The authid the client wants to authenticate as.
- authrole (str or None) – The authrole the client wants to authenticate as.
- authextra (arbitrary or None) – Any extra information the specific authentication method requires the client to send.
- session_roles (dict or None) – The WAMP session roles and features by the connecting client.
- pending_session (int or None) – The session ID the session will get once successfully attached.
- resumable (bool or None) –
- resume_session (int or None) – The session the client would like to resume.
- resume_token (str or None) – The secure authorisation token to resume the session.
-
class
autobahn.wamp.types.SessionDetails(realm, session, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None, resumed=None, resumable=None, resume_token=None)[source]¶ Provides details for a WAMP session upon open.
Parameters: - realm (str) – The realm this WAMP session is attached to.
- session (int) – WAMP session ID of this session.
- resumed (bool or None) – Whether the session is a resumed one.
- resumable (bool or None) – Whether this session can be resumed later.
- resume_token (str or None) – The secure authorisation token to resume the session.
-
class
autobahn.wamp.types.CloseDetails(reason=None, message=None)[source]¶ Provides details for a WAMP session upon close.
Parameters:
-
class
autobahn.wamp.types.SubscribeOptions(match=None, details=None, details_arg=None, get_retained=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]¶ Used to provide options for subscribing in
autobahn.wamp.interfaces.ISubscriber.subscribe().Parameters: - match (str) – The topic matching method to be used for the subscription.
- details (bool) – When invoking the handler, provide event details in a keyword
parameter
details. - details_arg (str) – DEPCREATED (use “details” flag). When invoking the handler provide event details in this keyword argument to the callable.
- get_retained (bool or None) – Whether the client wants the retained message we may have along with the subscription.
-
class
autobahn.wamp.types.EventDetails(subscription, publication, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, enc_algo=None)[source]¶ Provides details on an event when calling an event handler previously registered.
Parameters: - subscription (instance of
autobahn.wamp.request.Subscription) – The (client side) subscription object on which this event is delivered. - publication (int) – The publication ID of the event (always present).
- publisher (None or int) – The WAMP session ID of the original publisher of this event. Only filled when publisher is disclosed.
- publisher_authid (str or None) – The WAMP authid of the original publisher of this event. Only filled when publisher is disclosed.
- publisher_authrole (str or None) – The WAMP authrole of the original publisher of this event. Only filled when publisher is disclosed.
- topic (str or None) – For pattern-based subscriptions, the actual topic URI being published to. Only filled for pattern-based subscriptions.
- retained (bool or None) – Whether the message was retained by the broker on the topic, rather than just published.
- enc_algo (str or None) – Payload encryption algorithm that
was in use (currently, either
Noneoru'cryptobox').
- subscription (instance of
-
class
autobahn.wamp.types.PublishOptions(acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]¶ Used to provide options for subscribing in
autobahn.wamp.interfaces.IPublisher.publish().Parameters: - acknowledge (bool) – If
True, acknowledge the publication with a success or error response. - exclude_me (bool or None) – If
True, exclude the publisher from receiving the event, even if he is subscribed (and eligible). - exclude (int or list of int or None) – A single WAMP session ID or a list thereof to exclude from receiving this event.
- exclude_authid (str or list of str or None) – A single WAMP authid or a list thereof to exclude from receiving this event.
- exclude_authrole (list of str or None) – A single WAMP authrole or a list thereof to exclude from receiving this event.
- eligible (int or list of int or None) – A single WAMP session ID or a list thereof eligible to receive this event.
- eligible_authid (str or list of str or None) – A single WAMP authid or a list thereof eligible to receive this event.
- eligible_authrole (str or list of str or None) – A single WAMP authrole or a list thereof eligible to receive this event.
- retain (bool or None) – If
True, request the broker retain this event.
- acknowledge (bool) – If
-
class
autobahn.wamp.types.RegisterOptions(match=None, invoke=None, concurrency=None, details_arg=None, force_reregister=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]¶ Used to provide options for registering in
autobahn.wamp.interfaces.ICallee.register().Parameters: - match – Type of matching to use on the URI (exact, prefix or wildcard)
- invoke – Type of invoke mechanism to use (single, first, last, roundrobin, random)
- concurrency – if used, the number of times a particular endpoint may be called concurrently (e.g. if this is 3, and there are already 3 calls in-progress a 4th call will receive an error)
- details_arg (str) – When invoking the endpoint, provide call details in this keyword argument to the callable.
- force_reregister – if True, any other session that has already registered this URI will be ‘kicked out’ and this session will become the one that’s registered (the previous session must have used force_reregister=True as well)
-
class
autobahn.wamp.types.CallDetails(registration, progress=None, caller=None, caller_authid=None, caller_authrole=None, procedure=None, enc_algo=None)[source]¶ Provides details on a call when an endpoint previously registered is being called and opted to receive call details.
Parameters: - registration (instance of
autobahn.wamp.request.Registration) – The (client side) registration object this invocation is delivered on. - progress (callable or None) – A callable that will receive progressive call results.
- caller (int or None) – The WAMP session ID of the caller, if the latter is disclosed. Only filled when caller is disclosed.
- caller_authid (str or None) – The WAMP authid of the original caller of this event. Only filled when caller is disclosed.
- caller_authrole (str or None) – The WAMP authrole of the original caller of this event. Only filled when caller is disclosed.
- procedure (str or None) – For pattern-based registrations, the actual procedure URI being called.
- enc_algo (str or None) – Payload encryption algorithm that was in use (currently, either None or “cryptobox”).
- registration (instance of
-
class
autobahn.wamp.types.CallOptions(on_progress=None, timeout=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]¶ Used to provide options for calling with
autobahn.wamp.interfaces.ICaller.call().Parameters:
-
class
autobahn.wamp.types.CallResult(*results, **kwresults)[source]¶ Wrapper for remote procedure call results that contain multiple positional return values or keyword-based return values.
Parameters:
-
class
autobahn.wamp.types.EncodedPayload(payload, enc_algo, enc_serializer=None, enc_key=None)[source]¶ Wrapper holding an encoded application payload when using WAMP payload transparency.
Parameters: - payload (bytes) – The encoded application payload.
- enc_algo (str) – The payload transparency algorithm identifier to check.
- enc_serializer (str) – The payload transparency serializer identifier to check.
- enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.
WAMP Exceptions¶
-
exception
autobahn.wamp.exception.SessionNotReady[source]¶ The application tried to perform a WAMP interaction, but the session is not yet fully established.
-
exception
autobahn.wamp.exception.SerializationError[source]¶ Exception raised when the WAMP serializer could not serialize the application payload (
argsorkwargsforCALL,PUBLISH, etc).
-
exception
autobahn.wamp.exception.ProtocolError[source]¶ Exception raised when WAMP protocol was violated. Protocol errors are fatal and are handled by the WAMP implementation. They are not supposed to be handled at the application level.
-
exception
autobahn.wamp.exception.TransportLost[source]¶ Exception raised when the transport underlying the WAMP session was lost or is not connected.
WAMP Authentication and Encryption¶
-
autobahn.wamp.auth.generate_totp_secret(length=10)[source]¶ Generates a new Base32 encoded, random secret.
See also
Parameters: length (int) – The length of the entropy used to generate the secret. Returns: The generated secret in Base32 (letters A-Zand digits2-7). The length of the generated secret islength * 8 / 5octets.Return type: unicode
-
autobahn.wamp.auth.compute_totp(secret, offset=0)[source]¶ Computes the current TOTP code.
Parameters: - secret (unicode) – Base32 encoded secret.
- offset (int) – Time offset (in steps, use eg -1, 0, +1 for compliance with RFC6238) for which to compute TOTP.
Returns: TOTP for current time (+/- offset).
Return type: unicode
-
autobahn.wamp.auth.pbkdf2(data, salt, iterations=1000, keylen=32, hashfunc=None)[source]¶ Returns a binary digest for the PBKDF2 hash algorithm of
datawith the givensalt. It iteratesiterationstime and produces a key ofkeylenbytes. By default SHA-256 is used as hash function, a different hashlibhashfunccan be provided.Parameters: - data (bytes) – The data for which to compute the PBKDF2 derived key.
- salt (bytes) – The salt to use for deriving the key.
- iterations (int) – The number of iterations to perform in PBKDF2.
- keylen (int) – The length of the cryptographic key to derive.
- hashfunc (callable) – The hash function to use, e.g.
hashlib.sha1.
Returns: The derived cryptographic key.
Return type:
-
autobahn.wamp.auth.derive_key(secret, salt, iterations=1000, keylen=32)[source]¶ Computes a derived cryptographic key from a password according to PBKDF2.
See also
Parameters: Returns: The derived key in Base64 encoding.
Return type:
-
autobahn.wamp.auth.generate_wcs(length=14)[source]¶ Generates a new random secret for use with WAMP-CRA.
The secret generated is a random character sequence drawn from
- upper and lower case latin letters
- digits
Parameters: length (int) – The length of the secret to generate. Returns: The generated secret. The length of the generated is lengthoctets.Return type: bytes
-
autobahn.wamp.auth.compute_wcs(key, challenge)[source]¶ Compute an WAMP-CRA authentication signature from an authentication challenge and a (derived) key.
Parameters: Returns: The authentication signature.
Return type:
-
class
autobahn.wamp.cryptobox.EncodedPayload(payload, enc_algo, enc_serializer=None, enc_key=None)[source]¶ Wrapper holding an encoded application payload when using WAMP payload transparency.
Parameters: - payload (bytes) – The encoded application payload.
- enc_algo (str) – The payload transparency algorithm identifier to check.
- enc_serializer (str) – The payload transparency serializer identifier to check.
- enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.