PolkitAgent.Session¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The cookie obtained from the PolicyKit daemon |
||
r/w/co |
The identity to authenticate |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the authentication session has been completed or cancelled. |
|
Emitted when the user is requested to answer a question. |
|
Emitted when there is information related to an error condition to be displayed to the user. |
|
Emitted when there is information to be displayed to the user. |
Fields¶
- Inherited:
Class Details¶
- class PolkitAgent.Session(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The
PolkitAgent.Session
class is an abstraction used for interacting with the native authentication system (for example PAM) for obtaining authorizations. This class is typically used together with instances that are derived from thePolkitAgent.Listener
abstract base class.To perform the actual authentication,
PolkitAgent.Session
uses a trusted suid helper. The authentication conversation is done through a pipe. This is transparent; the user only need to handle thePolkitAgent.Session
::request
,PolkitAgent.Session
::show-info
,PolkitAgent.Session
::show-error
andPolkitAgent.Session
::completed
signals and invokePolkitAgent.Session.response
() in response to requests.If the user successfully authenticates, the authentication helper will invoke a method on the PolicyKit daemon (see
Polkit.Authority.authentication_agent_response_sync
()) with the given cookie. Upon receiving a positive response from the PolicyKit daemon (via the authentication helper), thePolkitAgent.Session
::completed
signal will be emitted with the gained_authorization paramter set toTrue
.If the user is unable to authenticate, the
PolkitAgent.Session
::completed
signal will be emitted with the gained_authorization paramter set toFalse
.- classmethod new(identity, cookie)¶
- Parameters:
identity (
Polkit.Identity
) – The identity to authenticate.cookie (
str
) – The cookie obtained from the PolicyKit daemon
- Returns:
A
PolkitAgent.Session
. Free withGObject.Object.unref
().- Return type:
Creates a new authentication session.
The caller should connect to the
PolkitAgent.Session
::request
,PolkitAgent.Session
::show-info
,PolkitAgent.Session
::show-error
andPolkitAgent.Session
::completed
signals and then callPolkitAgent.Session.initiate
() to initiate the authentication session.
- cancel()¶
Cancels an authentication session. This will make self emit the
PolkitAgent.Session
::completed
signal.
- initiate()¶
Initiates the authentication session. Before calling this method, make sure to connect to the various signals. The signals will be emitted in the
thread-default main loop
that this method is invoked from.Use
PolkitAgent.Session.cancel
() to cancel the session.
- response(response)¶
- Parameters:
response (
str
) – Response from the user, typically a password.
Function for providing response to requests received via the
PolkitAgent.Session
::request
signal.
Signal Details¶
- PolkitAgent.Session.signals.completed(session, gained_authorization)¶
- Signal Name:
completed
- Flags:
- Parameters:
session (
PolkitAgent.Session
) – The object which received the signalgained_authorization (
bool
) –True
only if the authorization was successfully obtained.
Emitted when the authentication session has been completed or cancelled. The gained_authorization parameter is
True
only if the user successfully authenticated.Upon receiving this signal, the user should free session using
GObject.Object.unref
().
- PolkitAgent.Session.signals.request(session, request, echo_on)¶
- Signal Name:
request
- Flags:
- Parameters:
session (
PolkitAgent.Session
) – The object which received the signalrequest (
str
) – The request to show the user, e.g. “name: “ or “password: “.echo_on (
bool
) –True
if the response to the request SHOULD be echoed on the screen,False
if the response MUST NOT be echoed to the screen.
Emitted when the user is requested to answer a question.
When the response has been collected from the user, call
PolkitAgent.Session.response
().
- PolkitAgent.Session.signals.show_error(session, text)¶
- Signal Name:
show-error
- Flags:
- Parameters:
session (
PolkitAgent.Session
) – The object which received the signaltext (
str
) – An error string to display to the user.
Emitted when there is information related to an error condition to be displayed to the user.
- PolkitAgent.Session.signals.show_info(session, text)¶
- Signal Name:
show-info
- Flags:
- Parameters:
session (
PolkitAgent.Session
) – The object which received the signaltext (
str
) – A string to display to the user.
Emitted when there is information to be displayed to the user.
Property Details¶
- PolkitAgent.Session.props.cookie¶
- Name:
cookie
- Type:
- Default Value:
- Flags:
The cookie obtained from the PolicyKit daemon
- PolkitAgent.Session.props.identity¶
- Name:
identity
- Type:
- Default Value:
- Flags:
The identity to authenticate.