spry-0.2.vapi 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /* spry-0.2.vapi generated by valac 0.56.19, do not modify. */
  2. [CCode (gir_namespace = "spry", gir_version = "0.2")]
  3. namespace Spry {
  4. namespace Actions {
  5. [CCode (cheader_filename = "spry-0.2.h")]
  6. public class AlterUserAction : Spry.Actions.UserManagementAction {
  7. public AlterUserAction ();
  8. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  9. protected virtual string date_of_birth_required_message { get; }
  10. protected virtual string duplicate_email_message { get; }
  11. protected virtual string duplicate_user_message { get; }
  12. protected virtual string duplicate_username_message { get; }
  13. protected virtual string invalid_date_of_birth_message { get; }
  14. protected virtual string invalid_email_message { get; }
  15. protected virtual string name_required_message { get; }
  16. protected virtual string password_too_common_message { get; }
  17. protected virtual string password_too_long_message { get; }
  18. protected virtual string password_too_short_message { get; }
  19. protected virtual string self_alter_message { get; }
  20. protected virtual string update_failed_message { get; }
  21. protected virtual string user_required_message { get; }
  22. protected virtual string user_updated_message { get; }
  23. protected virtual string username_too_short_message { get; }
  24. }
  25. [CCode (cheader_filename = "spry-0.2.h")]
  26. public class ChangePasswordAction : Statum.StatumAction {
  27. public ChangePasswordAction ();
  28. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  29. protected virtual string change_failed_message { get; }
  30. protected virtual string current_password_invalid_message { get; }
  31. protected virtual string current_password_required_message { get; }
  32. protected virtual string login_uri { get; }
  33. protected virtual string password_changed_message { get; }
  34. protected virtual string password_mismatch_message { get; }
  35. protected virtual string password_too_common_message { get; }
  36. protected virtual string password_too_long_message { get; }
  37. protected virtual string password_too_short_message { get; }
  38. }
  39. [CCode (cheader_filename = "spry-0.2.h")]
  40. public class CreateProviderAction : Spry.Actions.ProviderManagementAction {
  41. public CreateProviderAction ();
  42. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  43. protected virtual string created_message { get; }
  44. }
  45. [CCode (cheader_filename = "spry-0.2.h")]
  46. public class DeleteProviderAction : Spry.Actions.ProviderManagementAction {
  47. public DeleteProviderAction ();
  48. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  49. protected virtual string deleted_message { get; }
  50. protected virtual string id_required_message { get; }
  51. }
  52. [CCode (cheader_filename = "spry-0.2.h")]
  53. public class DeleteUserAction : Spry.Actions.UserManagementAction {
  54. public DeleteUserAction ();
  55. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  56. protected virtual string delete_failed_message { get; }
  57. protected virtual string self_delete_message { get; }
  58. protected virtual string user_deleted_message { get; }
  59. protected virtual string user_required_message { get; }
  60. }
  61. [CCode (cheader_filename = "spry-0.2.h")]
  62. public class GrantPermissionAction : Spry.Actions.UserManagementAction {
  63. public GrantPermissionAction ();
  64. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  65. protected virtual string grant_failed_message { get; }
  66. protected virtual string permission_granted_message { get; }
  67. protected virtual string permission_required_message { get; }
  68. protected virtual string user_required_message { get; }
  69. }
  70. [CCode (cheader_filename = "spry-0.2.h")]
  71. public class LoginAction : Statum.StatumAction {
  72. public LoginAction ();
  73. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  74. protected virtual string invalid_credentials_message { get; }
  75. protected virtual string landing_uri { get; }
  76. }
  77. [CCode (cheader_filename = "spry-0.2.h")]
  78. public class LogoutAction : Statum.StatumAction {
  79. public LogoutAction ();
  80. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  81. protected virtual string logged_out_uri { get; }
  82. }
  83. [CCode (cheader_filename = "spry-0.2.h")]
  84. public class ProfileValidation : GLib.Object {
  85. public class Fields : GLib.Object {
  86. public GLib.DateTime date_of_birth { get; private set; }
  87. public string email { get; private set; }
  88. public string forename { get; private set; }
  89. public string surname { get; private set; }
  90. public string username { get; private set; }
  91. }
  92. public class PasswordPolicy : GLib.Object {
  93. public enum Rejection {
  94. TOO_SHORT,
  95. TOO_LONG,
  96. TOO_COMMON
  97. }
  98. public const int ADMIN_MIN_LENGTH;
  99. public const string[] DENY_LIST;
  100. public const int MAX_LENGTH;
  101. public const int MIN_LENGTH;
  102. public PasswordPolicy ();
  103. public static Spry.Actions.ProfileValidation.PasswordPolicy.Rejection? assess (string password);
  104. public static bool is_denied (string password);
  105. }
  106. public enum Rejection {
  107. USERNAME_TOO_SHORT,
  108. INVALID_EMAIL,
  109. NAME_REQUIRED,
  110. DATE_OF_BIRTH_REQUIRED,
  111. INVALID_DATE_OF_BIRTH
  112. }
  113. public ProfileValidation ();
  114. public static string? duplicate_message (GLib.Error e, string username_message, string email_message, string other_message);
  115. public static string internal_error_message (GLib.Error e, string message);
  116. public static string password_rejection_message (Spry.Actions.ProfileValidation.PasswordPolicy.Rejection rejection, string too_short_message, string too_long_message, string too_common_message);
  117. public static Spry.Actions.ProfileValidation.Fields? validate (Statum.StatumRequest request, out Spry.Actions.ProfileValidation.Rejection rejection);
  118. }
  119. [CCode (cheader_filename = "spry-0.2.h")]
  120. public abstract class ProviderManagementAction : Statum.StatumAction {
  121. protected Spry.Sso.ProviderService providers;
  122. protected ProviderManagementAction ();
  123. protected string form_auth_method ();
  124. protected string form_client_id ();
  125. protected string form_client_secret ();
  126. protected string form_display_name ();
  127. protected bool form_enabled ();
  128. protected string form_issuer ();
  129. protected string form_scope ();
  130. protected string form_slug ();
  131. protected Statum.DirectiveBuilder invalid (GLib.Error e);
  132. protected async Statum.DirectiveBuilder? require_permission_guard ();
  133. protected int64 target_provider_id ();
  134. protected virtual string required_permission { get; }
  135. protected virtual string unauthorised_uri { get; }
  136. }
  137. [CCode (cheader_filename = "spry-0.2.h")]
  138. public class PushSubscribeAction : Statum.StatumAction {
  139. public PushSubscribeAction ();
  140. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  141. protected virtual string invalid_subscription_message { get; }
  142. protected virtual string login_uri { get; }
  143. protected virtual string subscribe_failed_message { get; }
  144. protected virtual string subscribed_message { get; }
  145. }
  146. [CCode (cheader_filename = "spry-0.2.h")]
  147. public class PushUnsubscribeAction : Statum.StatumAction {
  148. public PushUnsubscribeAction ();
  149. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  150. protected virtual string endpoint_required_message { get; }
  151. protected virtual string login_uri { get; }
  152. protected virtual string unsubscribe_failed_message { get; }
  153. protected virtual string unsubscribed_message { get; }
  154. }
  155. [CCode (cheader_filename = "spry-0.2.h")]
  156. public class RegisterAction : Statum.StatumAction {
  157. public RegisterAction ();
  158. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  159. protected virtual string account_created_message { get; }
  160. protected virtual string date_of_birth_required_message { get; }
  161. protected virtual string duplicate_email_message { get; }
  162. protected virtual string duplicate_user_message { get; }
  163. protected virtual string duplicate_username_message { get; }
  164. protected virtual string invalid_date_of_birth_message { get; }
  165. protected virtual string invalid_email_message { get; }
  166. protected virtual string login_uri { get; }
  167. protected virtual string name_required_message { get; }
  168. protected virtual string password_mismatch_message { get; }
  169. protected virtual string password_too_common_message { get; }
  170. protected virtual string password_too_long_message { get; }
  171. protected virtual string password_too_short_message { get; }
  172. protected virtual string registration_failed_message { get; }
  173. protected virtual string username_too_short_message { get; }
  174. }
  175. [CCode (cheader_filename = "spry-0.2.h")]
  176. public class RevokePermissionAction : Spry.Actions.UserManagementAction {
  177. public RevokePermissionAction ();
  178. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  179. protected virtual string permission_required_message { get; }
  180. protected virtual string permission_revoked_message { get; }
  181. protected virtual string revoke_failed_message { get; }
  182. protected virtual string user_required_message { get; }
  183. }
  184. [CCode (cheader_filename = "spry-0.2.h")]
  185. public class SetProviderEnabledAction : Spry.Actions.ProviderManagementAction {
  186. public SetProviderEnabledAction ();
  187. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  188. protected virtual string id_required_message { get; }
  189. protected virtual string toggled_message { get; }
  190. }
  191. [CCode (cheader_filename = "spry-0.2.h")]
  192. public class SetUserEnabledAction : Spry.Actions.UserManagementAction {
  193. public SetUserEnabledAction ();
  194. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  195. protected virtual string update_failed_message { get; }
  196. protected virtual string user_disabled_message { get; }
  197. protected virtual string user_enabled_message { get; }
  198. protected virtual string user_required_message { get; }
  199. }
  200. [CCode (cheader_filename = "spry-0.2.h")]
  201. public abstract class SsoAction : Statum.StatumAction {
  202. protected Spry.Sso.SsoService sso;
  203. protected SsoAction ();
  204. protected Statum.DirectiveBuilder login_failed (GLib.Error e, string slug);
  205. protected string redirect_uri_for (string slug);
  206. protected string request_origin ();
  207. protected virtual string login_failed_message { get; }
  208. protected Astralis.HttpContext? request_http { get; private set; }
  209. }
  210. [CCode (cheader_filename = "spry-0.2.h")]
  211. public class SsoLoginAction : Spry.Actions.SsoAction {
  212. public SsoLoginAction ();
  213. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  214. }
  215. [CCode (cheader_filename = "spry-0.2.h")]
  216. public class UpdateProviderAction : Spry.Actions.ProviderManagementAction {
  217. public UpdateProviderAction ();
  218. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  219. protected virtual string id_required_message { get; }
  220. protected virtual string updated_message { get; }
  221. }
  222. [CCode (cheader_filename = "spry-0.2.h")]
  223. public class UserActionPrivate : GLib.Object {
  224. public UserActionPrivate ();
  225. public int64 user_id { get; set; }
  226. }
  227. [CCode (cheader_filename = "spry-0.2.h")]
  228. public abstract class UserManagementAction : Statum.StatumAction {
  229. protected Spry.Authentication.UserService users;
  230. protected UserManagementAction ();
  231. protected async Statum.DirectiveBuilder? require_permission_guard ();
  232. protected string target_permission ();
  233. protected int64 target_user_id ();
  234. protected override string private_namespace { get; }
  235. protected virtual string required_permission { get; }
  236. protected virtual string unauthorised_uri { get; }
  237. }
  238. }
  239. namespace Authentication {
  240. namespace Migrations {
  241. [CCode (cheader_filename = "spry-0.2.h")]
  242. public class M0001_Initial : InvercargillSql.Migrations.Migration {
  243. public M0001_Initial ();
  244. public override void down (InvercargillSql.Migrations.MigrationBuilder b);
  245. public override void up (InvercargillSql.Migrations.MigrationBuilder b);
  246. public override string migration_namespace { get; }
  247. public override string name { get; }
  248. public override uint64 serial { get; }
  249. }
  250. [CCode (cheader_filename = "spry-0.2.h")]
  251. public class M0002_SessionsValidAfter : InvercargillSql.Migrations.Migration {
  252. public M0002_SessionsValidAfter ();
  253. public override void down (InvercargillSql.Migrations.MigrationBuilder b);
  254. public override void up (InvercargillSql.Migrations.MigrationBuilder b);
  255. public override string migration_namespace { get; }
  256. public override string name { get; }
  257. public override uint64 serial { get; }
  258. }
  259. }
  260. [CCode (cheader_filename = "spry-0.2.h")]
  261. public class UserEntity : GLib.Object {
  262. public UserEntity ();
  263. public static void entity_mapping (InvercargillSql.Orm.EntityMapperBuilder<Spry.Authentication.UserEntity> cfg);
  264. public static GLib.DateTime EPOCH { get; }
  265. public GLib.DateTime created { get; set; }
  266. public GLib.DateTime date_of_birth { get; set; }
  267. public GLib.DateTime effective_sessions_valid_after { get; }
  268. public string email { get; set; }
  269. public bool enabled { get; set; }
  270. public string forename { get; set; }
  271. public int64 id { get; set; }
  272. public GLib.DateTime modified { get; set; }
  273. public string password_hash { get; set; }
  274. public GLib.DateTime? sessions_valid_after { get; set; }
  275. public string surname { get; set; }
  276. public string username { get; set; }
  277. }
  278. [CCode (cheader_filename = "spry-0.2.h")]
  279. public class UserPermissionEntity : GLib.Object {
  280. public UserPermissionEntity ();
  281. public static void entity_mapping (InvercargillSql.Orm.EntityMapperBuilder<Spry.Authentication.UserPermissionEntity> cfg);
  282. public int64 id { get; set; }
  283. public string permission { get; set; }
  284. public int64 user_id { get; set; }
  285. }
  286. [CCode (cheader_filename = "spry-0.2.h")]
  287. public class UserProjection : GLib.Object {
  288. public UserProjection ();
  289. public static void projection_mapping (InvercargillSql.Orm.Projections.ProjectionBuilder<Spry.Authentication.UserProjection> cfg) throws GLib.Error;
  290. public GLib.DateTime created { get; set; }
  291. public GLib.DateTime date_of_birth { get; set; }
  292. public GLib.DateTime effective_sessions_valid_after { get; }
  293. public string email { get; set; }
  294. public bool enabled { get; set; }
  295. public string forename { get; set; }
  296. public int64 id { get; set; }
  297. public GLib.DateTime modified { get; set; }
  298. public string password_hash { get; set; }
  299. public Invercargill.ImmutableLot<string> permissions { owned get; }
  300. public GLib.DateTime? sessions_valid_after { get; set; }
  301. public string surname { get; set; }
  302. public string username { get; }
  303. }
  304. [CCode (cheader_filename = "spry-0.2.h")]
  305. public class UserService : GLib.Object {
  306. public struct HashParameters {
  307. public string algorithm;
  308. public int version;
  309. public int64 memory;
  310. public int64 passes;
  311. public int64 parallelism;
  312. }
  313. public UserService ();
  314. public async Spry.Authentication.UserEntity alter_user (int64 user_id, string username, string email, string forename, string surname, GLib.DateTime date_of_birth, bool enabled) throws GLib.Error;
  315. public async Spry.Authentication.UserProjection? authenticate_user (string username, string password) throws GLib.Error;
  316. public async void clear_user_permissions (int64 user_id) throws GLib.Error;
  317. public async void delete_user (int64 user_id) throws GLib.Error;
  318. public static bool frame_is_valid_at (Spry.Authentication.UserProjection user, GLib.DateTime as_at);
  319. public async Spry.Authentication.UserProjection? get_user (int64 user_id) throws GLib.Error;
  320. public async Spry.Authentication.UserProjection? get_user_by_username (string username) throws GLib.Error;
  321. public async Invercargill.ImmutableLot<string> get_user_permissions (int64 user_id) throws GLib.Error;
  322. public static bool hash_needs_rehash (string hash_text);
  323. public async Invercargill.ImmutableLot<Spry.Authentication.UserProjection> list_users (int64 offset = 0, int64 limit = 100) throws GLib.Error;
  324. public static Spry.Authentication.UserService.HashParameters? parse_hash_parameters (string hash_text);
  325. public async Spry.Authentication.UserEntity register_user (string username, string email, string forename, string surname, GLib.DateTime date_of_birth, string password, bool enabled = true) throws GLib.Error;
  326. public async void rehash_password (int64 user_id, string password) throws GLib.Error;
  327. public async void remove_user_permission (int64 user_id, string permission) throws GLib.Error;
  328. public static GLib.DateTime session_epoch_now ();
  329. public async void set_password (int64 user_id, string password) throws GLib.Error;
  330. public async void set_user_enabled (int64 user_id, bool enabled) throws GLib.Error;
  331. public async void set_user_permission (int64 user_id, string permission) throws GLib.Error;
  332. }
  333. [CCode (cheader_filename = "spry-0.2.h")]
  334. public errordomain UserServiceError {
  335. USER_NOT_FOUND
  336. }
  337. }
  338. namespace Push {
  339. namespace Migrations {
  340. [CCode (cheader_filename = "spry-0.2.h")]
  341. public class M0003_PushSubscriptions : InvercargillSql.Migrations.Migration {
  342. public M0003_PushSubscriptions ();
  343. public override void down (InvercargillSql.Migrations.MigrationBuilder b);
  344. public override void up (InvercargillSql.Migrations.MigrationBuilder b);
  345. public override string migration_namespace { get; }
  346. public override string name { get; }
  347. public override uint64 serial { get; }
  348. }
  349. }
  350. [CCode (cheader_filename = "spry-0.2.h")]
  351. public class PushSender : GLib.Object {
  352. public Astralis.WebConfig? config;
  353. public const int ATTEMPTS;
  354. public const string DEFAULT_SUBJECT;
  355. public const int DEFAULT_TTL_SECONDS;
  356. public const uint RETRY_DELAY_MS;
  357. public PushSender ();
  358. public bool is_configured ();
  359. public void reload ();
  360. public async Spry.Push.DeliveryOutcome send_to_subscription (Spry.Push.PushService pushes, Spry.Push.PushSubscriptionEntity row, string payload, int ttl_seconds) throws GLib.Error;
  361. public async Spry.Push.DeliveryOutcome[] send_to_user (Spry.Push.PushService pushes, int64 user_id, string payload, int ttl_seconds = DEFAULT_TTL_SECONDS) throws GLib.Error;
  362. public string vapid_public_key ();
  363. }
  364. [CCode (cheader_filename = "spry-0.2.h")]
  365. public class PushService : GLib.Object {
  366. public PushService ();
  367. public async void forget (int64 subscription_id) throws GLib.Error;
  368. public async Spry.Push.PushSubscriptionEntity? get_by_endpoint (string endpoint) throws GLib.Error;
  369. public async Spry.Push.PushSubscriptionEntity subscribe (int64 user_id, string endpoint, string p256dh_b64, string auth_b64) throws GLib.Error;
  370. public async Invercargill.ImmutableLot<Spry.Push.PushSubscriptionEntity> subscriptions_for (int64 user_id) throws GLib.Error;
  371. public async bool unsubscribe (int64 user_id, string endpoint) throws GLib.Error;
  372. public async int unsubscribe_for_user (int64 user_id) throws GLib.Error;
  373. }
  374. [CCode (cheader_filename = "spry-0.2.h")]
  375. public class PushSubscriptionEntity : GLib.Object {
  376. public PushSubscriptionEntity ();
  377. public static void entity_mapping (InvercargillSql.Orm.EntityMapperBuilder<Spry.Push.PushSubscriptionEntity> cfg);
  378. public Locksmith.WebPush.Subscription to_subscription () throws Locksmith.Error;
  379. public string auth { get; set; }
  380. public GLib.DateTime created { get; set; }
  381. public string endpoint { get; set; }
  382. public int64 id { get; set; }
  383. public string p256dh { get; set; }
  384. public int64 user_id { get; set; }
  385. }
  386. [CCode (cheader_filename = "spry-0.2.h")]
  387. public enum DeliveryOutcome {
  388. DELIVERED,
  389. UNAUTHORIZED,
  390. GONE,
  391. RETRYABLE,
  392. SKIPPED
  393. }
  394. }
  395. namespace Resources {
  396. [CCode (cheader_filename = "spry-0.2.h")]
  397. public class SpryCss : Statum.ConstantStatumResource {
  398. public SpryCss ();
  399. public override string get_best_encoding (Invercargill.Set<string> supported);
  400. public override unowned uint8[] get_encoding (string encoding);
  401. public override string content_type { get; }
  402. public override string file_hash { get; }
  403. public override string name { get; }
  404. }
  405. [CCode (cheader_filename = "spry-0.2.h")]
  406. public class SpryPushJs : Statum.ConstantStatumResource {
  407. public SpryPushJs ();
  408. public override string get_best_encoding (Invercargill.Set<string> supported);
  409. public override unowned uint8[] get_encoding (string encoding);
  410. public override string content_type { get; }
  411. public override string file_hash { get; }
  412. public override string name { get; }
  413. }
  414. [CCode (cheader_filename = "spry-0.2.h")]
  415. public class SpryThemeAiry : Statum.ConstantStatumResource {
  416. public SpryThemeAiry ();
  417. public override string get_best_encoding (Invercargill.Set<string> supported);
  418. public override unowned uint8[] get_encoding (string encoding);
  419. public override string content_type { get; }
  420. public override string file_hash { get; }
  421. public override string name { get; }
  422. }
  423. [CCode (cheader_filename = "spry-0.2.h")]
  424. public class SpryThemeDwarf : Statum.ConstantStatumResource {
  425. public SpryThemeDwarf ();
  426. public override string get_best_encoding (Invercargill.Set<string> supported);
  427. public override unowned uint8[] get_encoding (string encoding);
  428. public override string content_type { get; }
  429. public override string file_hash { get; }
  430. public override string name { get; }
  431. }
  432. [CCode (cheader_filename = "spry-0.2.h")]
  433. public class SpryThemeFormal : Statum.ConstantStatumResource {
  434. public SpryThemeFormal ();
  435. public override string get_best_encoding (Invercargill.Set<string> supported);
  436. public override unowned uint8[] get_encoding (string encoding);
  437. public override string content_type { get; }
  438. public override string file_hash { get; }
  439. public override string name { get; }
  440. }
  441. [CCode (cheader_filename = "spry-0.2.h")]
  442. public class SpryThemeGlassy : Statum.ConstantStatumResource {
  443. public SpryThemeGlassy ();
  444. public override string get_best_encoding (Invercargill.Set<string> supported);
  445. public override unowned uint8[] get_encoding (string encoding);
  446. public override string content_type { get; }
  447. public override string file_hash { get; }
  448. public override string name { get; }
  449. }
  450. [CCode (cheader_filename = "spry-0.2.h")]
  451. public class SpryThemeH2o : Statum.ConstantStatumResource {
  452. public SpryThemeH2o ();
  453. public override string get_best_encoding (Invercargill.Set<string> supported);
  454. public override unowned uint8[] get_encoding (string encoding);
  455. public override string content_type { get; }
  456. public override string file_hash { get; }
  457. public override string name { get; }
  458. }
  459. [CCode (cheader_filename = "spry-0.2.h")]
  460. public class SpryThemeLivingSky : Statum.ConstantStatumResource {
  461. public SpryThemeLivingSky ();
  462. public override string get_best_encoding (Invercargill.Set<string> supported);
  463. public override unowned uint8[] get_encoding (string encoding);
  464. public override string content_type { get; }
  465. public override string file_hash { get; }
  466. public override string name { get; }
  467. }
  468. [CCode (cheader_filename = "spry-0.2.h")]
  469. public class SpryThemeModern : Statum.ConstantStatumResource {
  470. public SpryThemeModern ();
  471. public override string get_best_encoding (Invercargill.Set<string> supported);
  472. public override unowned uint8[] get_encoding (string encoding);
  473. public override string content_type { get; }
  474. public override string file_hash { get; }
  475. public override string name { get; }
  476. }
  477. }
  478. namespace Sso {
  479. namespace Migrations {
  480. [CCode (cheader_filename = "spry-0.2.h")]
  481. public class M0004_OAuthProviders : InvercargillSql.Migrations.Migration {
  482. public M0004_OAuthProviders ();
  483. public override void down (InvercargillSql.Migrations.MigrationBuilder b);
  484. public override void up (InvercargillSql.Migrations.MigrationBuilder b);
  485. public override string migration_namespace { get; }
  486. public override string name { get; }
  487. public override uint64 serial { get; }
  488. }
  489. [CCode (cheader_filename = "spry-0.2.h")]
  490. public class M0005_OAuthIdentities : InvercargillSql.Migrations.Migration {
  491. public M0005_OAuthIdentities ();
  492. public override void down (InvercargillSql.Migrations.MigrationBuilder b);
  493. public override void up (InvercargillSql.Migrations.MigrationBuilder b);
  494. public override string migration_namespace { get; }
  495. public override string name { get; }
  496. public override uint64 serial { get; }
  497. }
  498. }
  499. [CCode (cheader_filename = "spry-0.2.h")]
  500. public class LoginAttempt : GLib.Object {
  501. public LoginAttempt ();
  502. public string authorize_uri { get; set; }
  503. public Spry.Sso.SsoService.SsoPrivate private_data { get; set; }
  504. public string provider_slug { get; set; }
  505. public Spry.Sso.SsoService.SsoPublic public_data { get; set; }
  506. }
  507. [CCode (cheader_filename = "spry-0.2.h")]
  508. public class LoginMode : GLib.Object {
  509. public enum Mode {
  510. PLAIN,
  511. HYBRID,
  512. SSO_ONLY
  513. }
  514. public LoginMode ();
  515. public static Spry.Sso.LoginMode resolve (Astralis.WebConfig? config);
  516. public bool is_hybrid { get; }
  517. public bool is_plain { get; }
  518. public bool is_sso_only { get; }
  519. public Spry.Sso.LoginMode.Mode mode { get; private set; }
  520. public string provider { get; private set; }
  521. }
  522. [CCode (cheader_filename = "spry-0.2.h")]
  523. public class OAuthIdentityEntity : GLib.Object {
  524. public OAuthIdentityEntity ();
  525. public static void entity_mapping (InvercargillSql.Orm.EntityMapperBuilder<Spry.Sso.OAuthIdentityEntity> cfg);
  526. public GLib.DateTime created { get; set; }
  527. public int64 id { get; set; }
  528. public string provider_slug { get; set; }
  529. public string subject { get; set; }
  530. public int64 user_id { get; set; }
  531. }
  532. [CCode (cheader_filename = "spry-0.2.h")]
  533. public class OAuthProviderEntity : GLib.Object {
  534. public const string DEFAULT_AUTH_METHOD;
  535. public const string DEFAULT_SCOPE;
  536. public OAuthProviderEntity ();
  537. public Locksmith.OAuth2.ClientAuthentication.Method authentication_method () throws Locksmith.Error;
  538. public static void entity_mapping (InvercargillSql.Orm.EntityMapperBuilder<Spry.Sso.OAuthProviderEntity> cfg);
  539. public string auth_method { get; set; }
  540. public string client_id { get; set; }
  541. public string client_secret { get; set; }
  542. public GLib.DateTime created { get; set; }
  543. public string display_name { get; set; }
  544. public string effective_scope { get; }
  545. public bool enabled { get; set; }
  546. public int64 id { get; set; }
  547. public string issuer { get; set; }
  548. public GLib.DateTime modified { get; set; }
  549. public string scope { get; set; }
  550. public string slug { get; set; }
  551. }
  552. [CCode (cheader_filename = "spry-0.2.h")]
  553. public class ProviderService : GLib.Object {
  554. public const string SLUG_ALPHABET;
  555. public ProviderService ();
  556. public async Spry.Sso.OAuthProviderEntity create_provider (string slug, string display_name, string issuer, string client_id, string client_secret, string scope = "", string auth_method = "", bool enabled = true) throws GLib.Error;
  557. public async int delete_identities_for_user (int64 user_id) throws GLib.Error;
  558. public async void delete_provider (int64 provider_id, bool delete_identities = false) throws GLib.Error;
  559. public async Spry.Sso.OAuthProviderEntity? get_by_id (int64 provider_id) throws GLib.Error;
  560. public async Spry.Sso.OAuthProviderEntity? get_by_slug (string slug) throws GLib.Error;
  561. public async Invercargill.ImmutableLot<Spry.Sso.OAuthProviderEntity> list_enabled_providers () throws GLib.Error;
  562. public async Invercargill.ImmutableLot<Spry.Sso.OAuthProviderEntity> list_providers () throws GLib.Error;
  563. public async Spry.Sso.OAuthProviderEntity set_enabled (int64 provider_id, bool enabled) throws GLib.Error;
  564. public async Spry.Sso.OAuthProviderEntity update_provider (int64 provider_id, string slug, string display_name, string issuer, string client_id, string client_secret, string scope = "", string auth_method = "", bool enabled = true) throws GLib.Error;
  565. }
  566. [CCode (cheader_filename = "spry-0.2.h")]
  567. public class SsoHttpClient : GLib.Object {
  568. public const uint CACHE_TTL_SECONDS;
  569. public const string OAUTH_WELL_KNOWN;
  570. public const string OIDC_WELL_KNOWN;
  571. public const uint TIMEOUT_SECONDS;
  572. public SsoHttpClient ();
  573. public async Locksmith.OAuth2.IssuerMetadata discover (string slug, string issuer) throws GLib.Error;
  574. public async string get_json (string userinfo_endpoint, string access_token) throws GLib.Error;
  575. public async string post_form (string token_endpoint, Locksmith.OAuth2.TokenRequest.Parts parts) throws GLib.Error;
  576. }
  577. [CCode (cheader_filename = "spry-0.2.h")]
  578. public class SsoService : GLib.Object {
  579. public class SsoPrivate : GLib.Object {
  580. public SsoPrivate ();
  581. public string provider { get; set; }
  582. public string state { get; set; }
  583. public string verifier { get; set; }
  584. }
  585. public class SsoPublic : GLib.Object {
  586. public SsoPublic ();
  587. public string provider { get; set; }
  588. }
  589. public const string SSO_SLOT_TYPE;
  590. public SsoService ();
  591. public async Spry.Sso.LoginAttempt begin_login (string slug, string redirect_uri) throws GLib.Error;
  592. public async Spry.Authentication.UserProjection complete_login (Spry.Sso.SsoService.SsoPrivate held, string code, string state, string redirect_uri) throws GLib.Error;
  593. public async Locksmith.OAuth2.IssuerMetadata discover (Spry.Sso.OAuthProviderEntity provider) throws GLib.Error;
  594. public async Spry.Sso.UserInfo fetch_userinfo (Spry.Sso.OAuthProviderEntity provider, Locksmith.OAuth2.IssuerMetadata metadata, string access_token) throws GLib.Error;
  595. public async Spry.Sso.OAuthProviderEntity require_provider (string slug) throws GLib.Error;
  596. public async Spry.Authentication.UserProjection resolve_identity (string provider_slug, Spry.Sso.UserInfo userinfo) throws GLib.Error;
  597. public async string unique_username (string candidate) throws GLib.Error;
  598. }
  599. [CCode (cheader_filename = "spry-0.2.h")]
  600. public class UserInfo : GLib.Object {
  601. public UserInfo ();
  602. public string email { get; set; }
  603. public string family_name { get; set; }
  604. public string given_name { get; set; }
  605. public string sub { get; set; }
  606. public string username { get; set; }
  607. }
  608. [CCode (cheader_filename = "spry-0.2.h")]
  609. public errordomain ProviderError {
  610. NOT_FOUND,
  611. DUPLICATE_SLUG,
  612. INVALID
  613. }
  614. [CCode (cheader_filename = "spry-0.2.h")]
  615. public errordomain SsoError {
  616. UNKNOWN_PROVIDER,
  617. PROVIDER_DISABLED,
  618. DISCOVERY_FAILED,
  619. TOKEN_EXCHANGE_FAILED,
  620. USERINFO_FAILED,
  621. ACCOUNT_UNAVAILABLE,
  622. CRYPTO
  623. }
  624. }
  625. [CCode (cheader_filename = "spry-0.2.h")]
  626. public class AuthPrivate : GLib.Object {
  627. public AuthPrivate ();
  628. public int64 user_id { get; set; }
  629. }
  630. [CCode (cheader_filename = "spry-0.2.h")]
  631. public class AuthPublic : GLib.Object {
  632. public AuthPublic ();
  633. public string display_name { get; set; }
  634. public Statum.Model.ActionDto? logout { get; set; }
  635. public string[] permissions { get; set; }
  636. public string username { get; set; }
  637. }
  638. [CCode (cheader_filename = "spry-0.2.h")]
  639. public class CurrentUser : GLib.Object {
  640. public CurrentUser ();
  641. public CurrentUser.authenticated (int64 user_id, string username, string display_name, string[] permissions);
  642. public bool has_permission (string permission);
  643. public string display_name { get; private set; }
  644. public bool is_anonymous { get; private set; }
  645. public string[] permissions { get; private set; }
  646. public int64 user_id { get; private set; }
  647. public string username { get; private set; }
  648. }
  649. [CCode (cheader_filename = "spry-0.2.h")]
  650. public class SpryAuth : GLib.Object {
  651. public const string ADMIN_PERMISSION;
  652. public const string SLOT_TYPE;
  653. public SpryAuth ();
  654. public static Spry.CurrentUser current (Statum.StatumRequest request);
  655. public static async void ensure_admin (Spry.Authentication.UserService users, string username, string email, string password) throws GLib.Error;
  656. public static Statum.DirectiveBuilder login (Statum.DirectiveBuilder directives, Spry.Authentication.UserProjection user, Statum.ActionRegistry action_registry) throws GLib.Error;
  657. public static Spry.Sso.LoginMode login_mode (Astralis.WebConfig? config);
  658. public static bool permission_matches (string[] patterns, string permission);
  659. public static void register_actions (Statum.StatumConfigurator cfg);
  660. public static Statum.DirectiveBuilder relogin (Statum.DirectiveBuilder directives, Spry.Authentication.UserProjection user, Statum.ActionRegistry action_registry) throws GLib.Error;
  661. public static async Statum.DirectiveBuilder? require_login (Statum.DirectiveBuilder directives, Statum.StatumRequest request, Spry.Authentication.UserService users, string redirect = "/login");
  662. public static async Statum.DirectiveBuilder? require_permission (Statum.DirectiveBuilder directives, Statum.StatumRequest request, Spry.Authentication.UserService users, string permission, string redirect = "/login");
  663. }
  664. [CCode (cheader_filename = "spry-0.2.h")]
  665. public class SpryModule : GLib.Object, Inversion.Module {
  666. public SpryModule ();
  667. }
  668. [CCode (cheader_filename = "spry-0.2.h")]
  669. public class SsoCallbackEntrypoint : Statum.StatumEntrypoint {
  670. public const string SSO_SLOT_TYPE;
  671. public SsoCallbackEntrypoint ();
  672. public override async Statum.DirectiveBuilder handle () throws GLib.Error;
  673. protected string request_origin ();
  674. public virtual string failure_uri { get; }
  675. public virtual string landing_uri { get; }
  676. public virtual string login_failed_message { get; }
  677. }
  678. }