summaryrefslogtreecommitdiffstats
path: root/src/auth/db-oauth2.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/auth/db-oauth2.h
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/auth/db-oauth2.h')
-rw-r--r--src/auth/db-oauth2.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/auth/db-oauth2.h b/src/auth/db-oauth2.h
new file mode 100644
index 0000000..cb653db
--- /dev/null
+++ b/src/auth/db-oauth2.h
@@ -0,0 +1,46 @@
+#ifndef DB_OAUTH2_H
+#define DB_OAUTH2_H 1
+
+struct db_oauth2;
+struct oauth2_request;
+struct db_oauth2_request;
+
+typedef void db_oauth2_lookup_callback_t(struct db_oauth2_request *request,
+ enum passdb_result result,
+ const char *error,
+ void *context);
+struct db_oauth2_request {
+ pool_t pool;
+ struct db_oauth2_request *prev,*next;
+
+ struct db_oauth2 *db;
+ struct oauth2_request *req;
+
+ /* username to match */
+ const char *username;
+ /* token to use */
+ const char *token;
+
+ struct auth_request *auth_request;
+ struct auth_fields *fields;
+
+ db_oauth2_lookup_callback_t *callback;
+ void *context;
+ verify_plain_callback_t *verify_callback;
+};
+
+
+struct db_oauth2 *db_oauth2_init(const char *config_path);
+
+void db_oauth2_ref(struct db_oauth2 *);
+void db_oauth2_unref(struct db_oauth2 **);
+
+bool db_oauth2_uses_password_grant(const struct db_oauth2 *db);
+
+void db_oauth2_lookup(struct db_oauth2 *db, struct db_oauth2_request *req, const char *token, struct auth_request *request, db_oauth2_lookup_callback_t *callback, void *context);
+#define db_oauth2_lookup(db, req, token, request, callback, context) \
+ db_oauth2_lookup(db, req, token - \
+ CALLBACK_TYPECHECK(callback, void(*)(struct db_oauth2_request *, enum passdb_result, const char*, typeof(context))), \
+ request, (db_oauth2_lookup_callback_t*)callback, (void*)context)
+
+#endif