Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add authentication #118

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Unreleased

**Added**

* Added authentication functionality described in [rosauth](http://wiki.ros.org/rosauth).

**Changed**

**Fixed**
Expand Down
29 changes: 29 additions & 0 deletions src/roslibpy/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,35 @@ def get_node_details(self, node, callback=None, errback=None):

return output

def authenticate(self, mac, client, dest, rand, t, level, end):
"""Sends an authorization request to the server.

Note:
Sends authentication on connection.

Args:
mac (:obj:`str`): MAC (hash) string given by the trusted source.
client (:obj:`str`): IP of the client.
dest (:obj:`str`): IP of the destination.
rand (:obj:`str`): Random string given by the trusted source.
t (:obj:`float`): Time of the authorization request.
level (:obj:`str`): User level as a string given by the client.
end (:obj:`float`): End time of the client's session.
"""
def _ready_callback(*args):
self.send_on_ready(Message({
'op' : 'auth',
'mac' : mac,
'client' : client,
'dest' : dest,
'rand' : rand,
't' : t,
'level' : level,
'end' : end,
}))

self.on('ready', _ready_callback)


if __name__ == "__main__":
FORMAT = "%(asctime)-15s [%(levelname)s] %(message)s"
Expand Down
Loading