Skip to content

Commit ed088b6

Browse files
authored
Merge pull request #118 from LKSeng/main
add authentication
2 parents 55e8f39 + 1f54407 commit ed088b6

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Unreleased
1212

1313
**Added**
1414

15+
* Added authentication functionality described in [rosauth](http://wiki.ros.org/rosauth).
16+
1517
**Changed**
1618

1719
**Fixed**

src/roslibpy/ros.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,35 @@ def get_node_details(self, node, callback=None, errback=None):
555555

556556
return output
557557

558+
def authenticate(self, mac, client, dest, rand, t, level, end):
559+
"""Sends an authorization request to the server.
560+
561+
Note:
562+
Sends authentication on connection.
563+
564+
Args:
565+
mac (:obj:`str`): MAC (hash) string given by the trusted source.
566+
client (:obj:`str`): IP of the client.
567+
dest (:obj:`str`): IP of the destination.
568+
rand (:obj:`str`): Random string given by the trusted source.
569+
t (:obj:`float`): Time of the authorization request.
570+
level (:obj:`str`): User level as a string given by the client.
571+
end (:obj:`float`): End time of the client's session.
572+
"""
573+
def _ready_callback(*args):
574+
self.send_on_ready(Message({
575+
'op' : 'auth',
576+
'mac' : mac,
577+
'client' : client,
578+
'dest' : dest,
579+
'rand' : rand,
580+
't' : t,
581+
'level' : level,
582+
'end' : end,
583+
}))
584+
585+
self.on('ready', _ready_callback)
586+
558587

559588
if __name__ == "__main__":
560589
FORMAT = "%(asctime)-15s [%(levelname)s] %(message)s"

0 commit comments

Comments
 (0)