Gio.DBusAuthObserver¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted to check if mechanism is allowed to be used. |
|
Emitted to check if a peer that is successfully authenticated is authorized. |
Fields¶
- Inherited:
Class Details¶
- class Gio.DBusAuthObserver(**kwargs)¶
- Bases:
- Abstract:
No
GDBusAuthObserver
provides a mechanism for participating in how a [class`Gio`.DBusServer] (or a [class`Gio`.DBusConnection]) authenticates remote peers.Simply instantiate a
GDBusAuthObserver
and connect to the signals you are interested in. Note that new signals may be added in the future.- Controlling Authentication Mechanisms
By default, a
GDBusServer
or server-sideGDBusConnection
will allow any authentication mechanism to be used. If you only want to allow D-Bus connections with theEXTERNAL
mechanism, 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:```c static
bool
on_allow_mechanism (Gio.DBusAuthObserver
*observer, conststr
*mechanism,object
user_data) { if (GLib.strcmp0
(mechanism, “EXTERNAL”) == 0) { returnTrue
; }return
False
; } ```- Controlling Authorization
By default, a
GDBusServer
or server-sideGDBusConnection
will accept connections from any successfully authenticated user (but not from anonymous connections using theANONYMOUS
mechanism). If you only want to allow D-Bus connections from processes owned by the same uid as the server, since GLib 2.68, you should use theG_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER
flag. It’s equivalent to the following signal handler:```c static
bool
on_authorize_authenticated_peer (Gio.DBusAuthObserver
*observer,Gio.IOStream
*stream,Gio.Credentials
*credentials,object
user_data) {bool
authorized;authorized =
False
; if (credentials !=None
) {Gio.Credentials
*own_credentials; own_credentials =Gio.Credentials.new
(); if (Gio.Credentials.is_same_user
(credentials, own_credentials,None
)) authorized =True
;GObject.Object.unref
(own_credentials); }return authorized; } ```
New in version 2.26.
- classmethod new()[source]¶
- Returns:
A
Gio.DBusAuthObserver
. Free withGObject.Object.unref
().- Return type:
Creates a new
Gio.DBusAuthObserver
object.New in version 2.26.
- allow_mechanism(mechanism)[source]¶
- Parameters:
mechanism (
str
) – The name of the mechanism, e.g.DBUS_COOKIE_SHA1
.- Returns:
True
if mechanism can be used to authenticate the other peer,False
if not.- Return type:
Emits the
Gio.DBusAuthObserver
::allow-mechanism
signal on self.New in version 2.34.
- authorize_authenticated_peer(stream, credentials)[source]¶
- Parameters:
stream (
Gio.IOStream
) – AGio.IOStream
for theGio.DBusConnection
.credentials (
Gio.Credentials
orNone
) – Credentials received from the peer orNone
.
- Returns:
- Return type:
Emits the
Gio.DBusAuthObserver
::authorize-authenticated-peer
signal on self.New in version 2.26.
Signal Details¶
- Gio.DBusAuthObserver.signals.allow_mechanism(d_bus_auth_observer, mechanism)¶
- Signal Name:
allow-mechanism
- Flags:
- Parameters:
d_bus_auth_observer (
Gio.DBusAuthObserver
) – The object which received the signalmechanism (
str
) – The name of the mechanism, e.g.DBUS_COOKIE_SHA1
.
- Returns:
True
if mechanism can be used to authenticate the other peer,False
if not.- Return type:
Emitted to check if mechanism is allowed to be used.
New in version 2.34.
- Gio.DBusAuthObserver.signals.authorize_authenticated_peer(d_bus_auth_observer, stream, credentials)¶
- Signal Name:
authorize-authenticated-peer
- Flags:
- Parameters:
d_bus_auth_observer (
Gio.DBusAuthObserver
) – The object which received the signalstream (
Gio.IOStream
) – AGio.IOStream
for theGio.DBusConnection
.credentials (
Gio.Credentials
orNone
) – 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.