GNOME Bugzilla – Bug 787073
rtsp-server permissions: need add_role() function that's bindings friendly and can be used in python
Last modified: 2018-07-13 08:56:52 UTC
In c we have : auth = gst_rtsp_auth_new (); [...] /* make user token */ token = gst_rtsp_token_new (GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING, "user", NULL); basic = gst_rtsp_auth_make_basic ("user", "password"); gst_rtsp_auth_add_basic (auth, basic, token); [...] /* configure in the server */ gst_rtsp_server_set_auth (server, auth); [and later] permissions = gst_rtsp_permissions_new (); gst_rtsp_permissions_add_role (permissions, "user", GST_RTSP_PERM_MEDIA_FACTORY_ACCESS, G_TYPE_BOOLEAN, TRUE, GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, G_TYPE_BOOLEAN, TRUE, NULL); gst_rtsp_media_factory_set_permissions (factory, permissions); but in python : auth = GstRtspServer.RTSPAuth() token = GstRtspServer.RTSPToken(GstRtspServer.RTSP_TOKEN_MEDIA_FACTORY_ROLE, GObject.TYPE_STRING, 'user', None) # But this fails with: # TypeError: Passing arguments to gi.types.Boxed.__init__() is deprecated. All arguments passed will be ignored. basic = auth.make_basic("user", "password") auth.add_basic(basic, token) server.set_auth(auth) [and later] permissions = GstRtspServer.RTSPPermissions() # but neither permissions nor auth have a method add_role(), which I need How to help ? Thank you Someone else get the problem here : https://github.com/thaytan/gst-rpicamsrc/issues/20
Seems like va_list is not compatible with GObjectIntrospection : https://wiki.gnome.org/Projects/GObjectIntrospection/WritingBindingableAPIs So authentication is not working at all with python Aurelien BOUIN
So we need to come up with functions that are bindable and that can be used to achieve the same thing. It appears the vararg bits are basically just read into a GstStructure, so maybe we can make a function that takes a GstStructure as argument. I assume there's decent-enough support in bindings for GstStructures, or at least some sugar in gst-python? (someone should test/confirm this) Alternatively, a function that takes a fieldname + GValue might work and we can then build up the GstStructure internally. Not entirely sure how GValue args get mapped for bindings though, if that's a good choice or not.
*** Bug 792547 has been marked as a duplicate of this bug. ***
@Tim-Philipp Can you give me some more direction for resolving this bug through the current Python bindings? I can look into doing something myself unless this has to be done at the rtsp-server addon level.
I don't think there is a solution with the current Python bindings. It needs new C API that is usable for bindings.
Created attachment 367007 [details] [review] rtsp-token: add some API to set fields from bindings
Created attachment 367008 [details] [review] rtsp-token: annotate constructors for bindings
With the above patches, this works for me now: import gi from gi.repository import Gst from gi.repository import GstRtspServer Gst.init() print(Gst.version_string()) server = GstRtspServer.RTSPServer() auth = GstRtspServer.RTSPAuth() #token = GstRtspServer.RTSPToken.new_empty() #token = GstRtspServer.RTSPToken.new() token = GstRtspServer.RTSPToken() print(token) token.set_string('role','user') print(token.get_string('role')) print(token.is_allowed('perm')) token.set_bool('perm',True) print(token.is_allowed('perm')) basic = auth.make_basic("user", "password") auth.add_basic(basic, token) server.set_auth(auth)
Pushed slightly modified version that uses _get_writable_structure() to make sure the token is writable: commit 8708262ebe27f04f66fad4448c95042713ea5d49 (HEAD -> master) Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jan 18 11:32:32 2018 +0000 rtsp-token: annotate constructors for bindings This maps _new_empty() to _new(), which also makes RTSPToken() work properly now. Since this API wasn't usable from bindings before, this should hopefully be fine. https://bugzilla.gnome.org/show_bug.cgi?id=787073 commit 54a8c6bddfb877c5eb953ffeb3892ceae4b91835 Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jan 18 11:07:45 2018 +0000 rtsp-token: add some API to set fields from bindings The existing functions are all vararg-based and as such not usable from bindings. https://bugzilla.gnome.org/show_bug.cgi?id=787073 commit b1f515178a363df0322d7adbd5754e1f6e2083c9 (HEAD -> master) Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jan 18 23:53:20 2018 +0000 permissions: add some new API to make this usable from bindings https://bugzilla.gnome.org/show_bug.cgi?id=787073 Probably needs more work for advanced use cases.
What's the release cycle like to get these fixes into aptitude? I'm running this in multiple operating systems (Windows, stretch) but getting it into stretch would be nice.
That's for the Debian release / stable updates team to decide and you should file a bug there or send a mail to them. I'll upload the fix to Debian unstable (and that way it will become part of the next stable release) once there is a new GStreamer release in a few weeks.
Thanks guys.
I always get the following error: ERROR rtspclient rtsp-client.c:1021:find_media: client 0xa9a0d080: not authorized to see factory path /test ERROR rtspclient rtsp-client.c:2907:handle_describe_request: client 0xa9a0d080: no media How do I set the right permissions for the factory via Python bindings? I tried the following, but it had no effect: perm = GstRtspServer.RTSPPermissions() perm.add_role("user") perm.add_permission_for_role("user", "media.factory.access", True) perm.add_permission_for_role("user", "media.factory.construct", True) factory.set_permissions(perm) Any idea? Thanks in advance!