summaryrefslogtreecommitdiff
path: root/include/auth.h
blob: 9224dde25fa6f65b490879437658471a1c617fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef ASTAL_AUTH_PAM_H
#define ASTAL_AUTH_PAM_H

#include <glib-object.h>
#include <gio/gio.h>

G_BEGIN_DECLS

#define ASTAL_AUTH_TYPE_PAM (astal_auth_pam_get_type())

G_DECLARE_FINAL_TYPE (AstalAuthPam, astal_auth_pam, ASTAL_AUTH, PAM, GObject)

/**
 * astal_auth_pam_set_username
 * @self: a AstalAuthPam object
 * @username: the new username
 *
 * Sets the username to be used for authentication. This must be set to
 * before calling start_authenticate.
 * Changing it afterwards has no effect on the authentication process.
 *
 * Defaults to the owner of the process.
 *
 */
void astal_auth_pam_set_username(AstalAuthPam *self, const gchar *username);

/**
 * astal_auth_pam_get_username
 * @self: a AstalAuthPam object
 *
 * Fetches the username from AsalAuthPam object.
 *
 * Returns: the username of the AsalAuthPam object. This string is
 * owned by the object and must not be modified or freed.
 */
const gchar *astal_auth_pam_get_username(AstalAuthPam *self);

/**
 * astal_auth_pam_set_service
 * @self: a AstalAuthPam object
 * @service: the pam service used for authentication
 *
 * Sets the service to be used for authentication. This must be set to
 * before calling start_authenticate.
 * Changing it afterwards has no effect on the authentication process.
 *
 * Defaults to `astal-auth`.
 *
 */
void astal_auth_pam_set_service(AstalAuthPam *self, const gchar *service);

/**
 * astal_auth_pam_get_service
 * @self: a AstalAuthPam
 *
 * Fetches the service from AsalAuthPam object.
 *
 * Returns: the service of the AsalAuthPam object. This string is
 * owned by the object and must not be modified or freed.
 */
const gchar *astal_auth_pam_get_service(AstalAuthPam *self);


/**
 * astal_auth_pam_start_authentication:
 * @self: a AstalAuthPam Object
 *
 * starts a new authentication process using the PAM (Pluggable Authentication Modules) system.
 * Note that this will cancel an already running authentication process
 * associated with this AstalAuthPam object.
 */
gboolean astal_auth_pam_start_authenticate(AstalAuthPam *self);

/**
 * astal_auth_pam_supply_secret
 * @self: a AstalAuthPam Object
 * @secret: (nullable): the secret to be provided to pam. Can be NULL.
 *
 * provides pam with a secret. This method must be called exactly once after a
 * auth-* signal is emitted.
 */
void astal_auth_pam_supply_secret(AstalAuthPam *self, const gchar *secret);

/**
 * astal_auth_pam_authenticate:
 * @password: the password to be authenticated
 * @result_callback: (scope async) (closure user_data): a GAsyncReadyCallback
 *   to call when the request is satisfied
 * @user_data: the data to pass to callback function
 *
 * Requests authentication of the provided password using the PAM (Pluggable Authentication Modules) system.
 */
gboolean astal_auth_pam_authenticate(const gchar *password,
                                     GAsyncReadyCallback result_callback,
                                     gpointer user_data);

gssize astal_auth_pam_authenticate_finish(GAsyncResult *res,
                                          GError **error);

G_END_DECLS

#endif // !ASTAL_AUTH_PAM_H