Gio.DBusAuthObserver¶
| Subclasses: | None |
|---|
Methods¶
| Inherited: | GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
| class | new () |
allow_mechanism (mechanism) |
|
authorize_authenticated_peer (stream, credentials) |
Virtual Methods¶
| Inherited: | GObject.Object (7) |
|---|
Properties¶
None
Signals¶
| Inherited: | GObject.Object (1) |
|---|
| Name | Short Description |
|---|---|
allow-mechanism |
Emitted to check if mechanism is allowed to be used. |
authorize-authenticated-peer |
Emitted to check if a peer that is successfully authenticated is authorized. |
Fields¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
Gio.DBusAuthObserver(**kwargs)¶ Bases: GObject.ObjectAbstract: No The
Gio.DBusAuthObservertype provides a mechanism for participating in how aGio.DBusServer(or aGio.DBusConnection) authenticates remote peers. Simply instantiate aGio.DBusAuthObserverand connect to the signals you are interested in. Note that new signals may be added in the future- Controlling Authentication Mechanisms
By default, a
Gio.DBusServeror server-sideGio.DBusConnectionwill allow any authentication mechanism to be used. If you only want to allow D-Bus connections with theEXTERNALmechanism, which makes use of credentials passing and is the recommended mechanism for modern Unix platforms such as Linux and the BSD family, you would use a signal handler like this:static gboolean on_allow_mechanism (GDBusAuthObserver *observer, const gchar *mechanism, gpointer user_data) { if (g_strcmp0 (mechanism, "EXTERNAL") == 0) { return TRUE; } return FALSE; }
- Controlling Authorization
By default, a
Gio.DBusServeror server-sideGio.DBusConnectionwill accept connections from any successfully authenticated user (but not from anonymous connections using theANONYMOUSmechanism). If you only want to allow D-Bus connections from processes owned by the same uid as the server, you would use a signal handler like the following:static gboolean on_authorize_authenticated_peer (GDBusAuthObserver *observer, GIOStream *stream, GCredentials *credentials, gpointer user_data) { gboolean authorized; authorized = FALSE; if (credentials != NULL) { GCredentials *own_credentials; own_credentials = g_credentials_new (); if (g_credentials_is_same_user (credentials, own_credentials, NULL)) authorized = TRUE; g_object_unref (own_credentials); } return authorized; }
New in version 2.26.
-
classmethod
new()[source]¶ Returns: A Gio.DBusAuthObserver. Free withGObject.Object.unref().Return type: Gio.DBusAuthObserverCreates a new
Gio.DBusAuthObserverobject.New in version 2.26.
-
allow_mechanism(mechanism)[source]¶ Parameters: mechanism ( str) – The name of the mechanism, e.g.DBUS_COOKIE_SHA1.Returns: Trueif mechanism can be used to authenticate the other peer,Falseif not.Return type: boolEmits the
Gio.DBusAuthObserver::allow-mechanismsignal on self.New in version 2.34.
Parameters: - stream (
Gio.IOStream) – AGio.IOStreamfor theGio.DBusConnection. - credentials (
Gio.CredentialsorNone) – Credentials received from the peer orNone.
Returns: Return type: Emits the
Gio.DBusAuthObserver::authorize-authenticated-peersignal on self.New in version 2.26.
- stream (
Signal Details¶
-
Gio.DBusAuthObserver.signals.allow_mechanism(d_bus_auth_observer, mechanism)¶ Signal Name: allow-mechanismFlags: Parameters: - d_bus_auth_observer (
Gio.DBusAuthObserver) – The object which received the signal - mechanism (
str) – The name of the mechanism, e.g.DBUS_COOKIE_SHA1.
Returns: Trueif mechanism can be used to authenticate the other peer,Falseif not.Return type: Emitted to check if mechanism is allowed to be used.
New in version 2.34.
- d_bus_auth_observer (
Signal Name: authorize-authenticated-peerFlags: Parameters: - d_bus_auth_observer (
Gio.DBusAuthObserver) – The object which received the signal - stream (
Gio.IOStream) – AGio.IOStreamfor theGio.DBusConnection. - credentials (
Gio.CredentialsorNone) – Credentials received from the peer orNone.
Returns: Return type: Emitted to check if a peer that is successfully authenticated is authorized.
New in version 2.26.
- d_bus_auth_observer (