summaryrefslogtreecommitdiff
path: root/auth/examples
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-09-01 14:17:36 +0200
committerAylur <[email protected]>2024-09-01 14:17:36 +0200
commit3e3f045d650a839d21f7b649da7aa5c19bd2e38b (patch)
tree9a974eb0d38932d474940288c662bd1f01ea3088 /auth/examples
parent408faee16911ccfaa3e7dad69f9938fd4a696704 (diff)
monorepo structuring
Diffstat (limited to 'auth/examples')
-rw-r--r--auth/examples/full_example.c66
-rw-r--r--auth/examples/full_example.js38
-rw-r--r--auth/examples/meson.build18
-rw-r--r--auth/examples/simple_example.c31
-rw-r--r--auth/examples/simple_example.js9
5 files changed, 0 insertions, 162 deletions
diff --git a/auth/examples/full_example.c b/auth/examples/full_example.c
deleted file mode 100644
index a20c02b..0000000
--- a/auth/examples/full_example.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <bsd/readpassphrase.h>
-
-#include "astal-auth.h"
-
-GMainLoop *loop;
-
-static void authenticate(AstalAuthPam *pam) {
- if (!astal_auth_pam_start_authenticate(pam)) {
- g_print("could not start authentication process\n");
- g_object_unref(pam);
- g_main_loop_quit(loop);
- }
-}
-
-static void on_visible(AstalAuthPam *pam, const gchar *data) {
- gchar passbuf[1024];
- readpassphrase(data, passbuf, sizeof(passbuf), RPP_ECHO_ON);
- astal_auth_pam_supply_secret(pam, passbuf);
-}
-
-static void on_hidden(AstalAuthPam *pam, const gchar *data) {
- gchar passbuf[1024];
- readpassphrase(data, passbuf, sizeof(passbuf), RPP_ECHO_OFF);
- astal_auth_pam_supply_secret(pam, passbuf);
-}
-
-static void on_info(AstalAuthPam *pam, const gchar *data) {
- g_print("info: %s\n", data);
- astal_auth_pam_supply_secret(pam, NULL);
-}
-
-static void on_error(AstalAuthPam *pam, const gchar *data) {
- g_print("error: %s\n", data);
- astal_auth_pam_supply_secret(pam, NULL);
-}
-
-static void on_success(AstalAuthPam *pam) {
- g_print("success\n");
- g_object_unref(pam);
- g_main_loop_quit(loop);
-}
-
-static void on_fail(AstalAuthPam *pam, const gchar *data) {
- g_print("fail: %s\n", data);
- authenticate(pam);
-}
-
-int main(void) {
- GMainContext *loopctx = NULL;
-
- loop = g_main_loop_new(loopctx, FALSE);
-
- AstalAuthPam *pam = g_object_new(ASTAL_AUTH_TYPE_PAM, NULL);
-
- g_signal_connect(pam, "auth-prompt-visible", G_CALLBACK(on_visible), NULL);
- g_signal_connect(pam, "auth-prompt-hidden", G_CALLBACK(on_hidden), NULL);
- g_signal_connect(pam, "auth-info", G_CALLBACK(on_info), NULL);
- g_signal_connect(pam, "auth-error", G_CALLBACK(on_error), NULL);
-
- g_signal_connect(pam, "success", G_CALLBACK(on_success), NULL);
- g_signal_connect(pam, "fail", G_CALLBACK(on_fail), NULL);
-
- authenticate(pam);
-
- g_main_loop_run(loop);
-}
diff --git a/auth/examples/full_example.js b/auth/examples/full_example.js
deleted file mode 100644
index 7359784..0000000
--- a/auth/examples/full_example.js
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env -S gjs -m
-
-import Auth from "gi://AstalAuth";
-import GLib from "gi://GLib";
-
-const loop = GLib.MainLoop.new(null, false);
-
-const pam = new Auth.Pam();
-pam.connect("auth-prompt-visible", (p, msg) => {
- print(msg);
- p.supply_secret("");
-});
-pam.connect("auth-prompt-hidden", (p, msg) => {
- print(msg);
- p.supply_secret("password");
-});
-pam.connect("auth-info", (p, msg) => {
- print(msg);
- p.supply_secret("");
-});
-pam.connect("auth-error", (p, msg) => {
- print(msg);
- p.supply_secret("");
-});
-
-pam.connect("success", p => {
- print("authentication sucessful");
- loop.quit();
-});
-pam.connect("fail", (p, msg) => {
- print(msg);
- loop.quit();
-});
-
-pam.start_authenticate();
-
-loop.runAsync()
-
diff --git a/auth/examples/meson.build b/auth/examples/meson.build
deleted file mode 100644
index cf23d3f..0000000
--- a/auth/examples/meson.build
+++ /dev/null
@@ -1,18 +0,0 @@
-
-deps_example = [
- dependency('gobject-2.0'),
- dependency('libbsd'),
- libastal_auth
-]
-
-astal_auth_full_exmple = executable(
- 'astal_auth_full_example',
- files('full_example.c'),
- dependencies : deps_example,
- install : false)
-
-astal_auth_simple_example = executable(
- 'astal_auth_simple_example',
- files('simple_example.c'),
- dependencies : deps_example,
- install : false)
diff --git a/auth/examples/simple_example.c b/auth/examples/simple_example.c
deleted file mode 100644
index d00bad2..0000000
--- a/auth/examples/simple_example.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <bsd/readpassphrase.h>
-
-#include "astal-auth.h"
-
-GMainLoop *loop;
-
-void ready_callback(AstalAuthPam *pam, GAsyncResult *res, gpointer user_data) {
- GError *error = NULL;
- astal_auth_pam_authenticate_finish(res, &error);
- if (error == NULL) {
- g_print("success\n");
- } else {
- g_print("failure: %s\n", error->message);
- g_error_free(error);
- }
-
- g_main_loop_quit(loop);
-}
-
-int main(void) {
- GMainContext *loopctx = NULL;
- loop = g_main_loop_new(loopctx, FALSE);
-
- gchar *passbuf = calloc(1024, sizeof(gchar));
- readpassphrase("Password: ", passbuf, 1024, RPP_ECHO_OFF);
- astal_auth_pam_authenticate(passbuf, (GAsyncReadyCallback)ready_callback, NULL);
- g_free(passbuf);
-
- g_main_loop_run(loop);
- exit(EXIT_SUCCESS);
-}
diff --git a/auth/examples/simple_example.js b/auth/examples/simple_example.js
deleted file mode 100644
index 2bf38c1..0000000
--- a/auth/examples/simple_example.js
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env -S gjs -m
-import Auth from "gi://AstalAuth";
-import Gio from "gi://Gio";
-
-Gio._promisify(Auth.Pam, "authenticate");
-
-await Auth.Pam.authenticate("password")
- .then(_ => print("authentication sucessful"))
- .catch(logError); \ No newline at end of file