Skip to content

Commit

Permalink
Nothrow on leave notjoined (#1542)
Browse files Browse the repository at this point in the history
* do not throw (but log) when leaving a session that is not joined
* never default set authid/authrole in component authenticators
* bump dev version
* update changelog
  • Loading branch information
oberstet committed Apr 4, 2022
1 parent 4f9216d commit b8b9096
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion autobahn/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
#
###############################################################################

__version__ = '22.4.1.dev1'
__version__ = '22.4.1.dev2'

__build__ = '00000000-0000000'
19 changes: 11 additions & 8 deletions autobahn/wamp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from autobahn.wamp import types
from autobahn.wamp import role
from autobahn.wamp import exception
from autobahn.wamp.exception import ApplicationError, ProtocolError, SessionNotReady, SerializationError, TypeCheckError
from autobahn.wamp.exception import ApplicationError, ProtocolError, SerializationError, TypeCheckError
from autobahn.wamp.interfaces import ISession, IPayloadCodec, IAuthenticator # noqa
from autobahn.wamp.types import SessionDetails, CloseDetails, EncodedPayload
from autobahn.exception import PayloadExceededError
Expand Down Expand Up @@ -1364,7 +1364,8 @@ def leave(self, reason=None, message=None):
Implements :meth:`autobahn.wamp.interfaces.ISession.leave`
"""
if not self._session_id:
raise SessionNotReady("session hasn't joined a realm")
self.log.warn('session is not joined on a realm - no session to leave')
return

if not self._goodbye_sent:
if not reason:
Expand Down Expand Up @@ -1804,8 +1805,8 @@ def onConnect(self):
self.join(
self.config.realm,
authmethods=list(self._authenticators.keys()),
authid=authid or 'public',
authrole=authrole or 'default',
authid=authid,
authrole=authrole,
authextra=authextra,
)
else:
Expand All @@ -1816,8 +1817,9 @@ def onChallenge(self, challenge):
authenticator = self._authenticators[challenge.method]
except KeyError:
raise RuntimeError(
"Received challenge for unknown authmethod '{}'".format(
challenge.method
"Received challenge for unknown authmethod '{}' [authenticators={}]".format(
challenge.method,
str(sorted(self._authenticators.keys()))
)
)
return authenticator.on_challenge(self, challenge)
Expand All @@ -1830,8 +1832,9 @@ def onWelcome(self, msg):
authenticator = self._authenticators[msg.authmethod]
except KeyError:
raise RuntimeError(
"Received onWelcome for unknown authmethod '{}'".format(
msg.authmethod
"Received onWelcome for unknown authmethod '{}' [authenticators={}]".format(
msg.authmethod,
str(sorted(self._authenticators.keys()))
)
)
return authenticator.on_welcome(self, msg.authextra)
Expand Down
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
Changelog
=========

22.4.1.devX
-----------

* fix: never default set authid/authrole in component authenticators
* fix: do not throw (but log) when leaving a session not joined
* fix: store WAMP authextra received

22.3.2
------

Expand Down

0 comments on commit b8b9096

Please sign in to comment.