alibi-core 0.8.0

Shared authentication contracts and backend-independent services for Alibi
Documentation
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
use crate::store::{
    ApiKeyStore, DeviceCodeStore, InvitationCreateOptions, InvitationStore, JwkStore,
    ListOrganizationMembersParams, MemberPageQuery, MemberStore, OrganizationRoleStore,
    OrganizationStore, PasskeyStore, PluginStore, TeamStore, TwoFactorStore,
};
use crate::types::{
    AddTeamMemberResult, CreateOrganizationRole, OrganizationRole, OrganizationRoleSelector,
    UpdateOrganizationRole, UpdatePasskeyAuthentication,
};
use crate::{
    ApiKey, AuthResult, AuthSchema, ConsumeApiKeyResult, CreateApiKey, CreateDeviceCode,
    CreateInvitation, CreateJwk, CreateMember, CreateOrganization, CreatePasskey, CreateTeam,
    CreateTwoFactor, CreateWalletAddress, DeviceCode, Invitation, InvitationStatus, Jwk, Member,
    Organization, Passkey, Team, TeamMember, TwoFactor, UpdateApiKey, UpdateDeviceCode,
    UpdateOrganization, UpdateTeam, UpdateTwoFactor, WalletAddress, WalletAddressStore,
};
use async_trait::async_trait;
use std::sync::Arc;
impl<S: AuthSchema> Clone for PluginStore<S> {
    fn clone(&self) -> Self {
        Self {
            ephemeral_sessions: Arc::clone(&self.ephemeral_sessions),
            inner: Arc::clone(&self.inner),
            config: Arc::clone(&self.config),
            transforms: self.transforms.clone(),
            session_callbacks: self.session_callbacks.clone(),
            session_fields: self.session_fields.clone(),
            adapter_fields: self.adapter_fields.clone(),
            projection_context: Arc::clone(&self.projection_context),
        }
    }
}

#[async_trait]
impl<S: AuthSchema> OrganizationStore for PluginStore<S> {
    async fn create_organization(&self, org: CreateOrganization) -> AuthResult<Organization> {
        self.inner.create_organization(org).await
    }
    async fn get_organization_by_id(&self, id: &str) -> AuthResult<Option<Organization>> {
        self.inner.get_organization_by_id(id).await
    }
    async fn get_organization_by_slug(&self, slug: &str) -> AuthResult<Option<Organization>> {
        self.inner.get_organization_by_slug(slug).await
    }
    async fn list_organizations_by_ids(&self, ids: &[String]) -> AuthResult<Vec<Organization>> {
        self.inner.list_organizations_by_ids(ids).await
    }
    async fn update_organization(
        &self,
        id: &str,
        update: UpdateOrganization,
    ) -> AuthResult<Organization> {
        self.inner.update_organization(id, update).await
    }
    async fn patch_organization_if_present(
        &self,
        id: &str,
        update: UpdateOrganization,
    ) -> AuthResult<Option<Organization>> {
        self.inner.patch_organization_if_present(id, update).await
    }
    async fn update_organization_if_present(
        &self,
        id: &str,
        update: UpdateOrganization,
    ) -> AuthResult<Option<Organization>> {
        self.inner.update_organization_if_present(id, update).await
    }
    async fn delete_organization(&self, id: &str) -> AuthResult<()> {
        self.inner.delete_organization(id).await
    }
    async fn list_user_organizations(&self, user_id: &str) -> AuthResult<Vec<Organization>> {
        self.inner.list_user_organizations(user_id).await
    }
}

#[async_trait]
impl<S: AuthSchema> MemberStore for PluginStore<S> {
    async fn create_member(&self, member: CreateMember) -> AuthResult<Member> {
        self.inner.create_member(member).await
    }
    async fn get_member(&self, organization_id: &str, user_id: &str) -> AuthResult<Option<Member>> {
        self.inner.get_member(organization_id, user_id).await
    }
    async fn get_member_by_id(&self, id: &str) -> AuthResult<Option<Member>> {
        self.inner.get_member_by_id(id).await
    }
    async fn update_member_role(&self, member_id: &str, role: &str) -> AuthResult<Member> {
        self.inner.update_member_role(member_id, role).await
    }
    async fn update_member_role_if_present(
        &self,
        member_id: &str,
        role: &str,
    ) -> AuthResult<Option<Member>> {
        self.inner
            .update_member_role_if_present(member_id, role)
            .await
    }
    async fn delete_member(&self, member_id: &str) -> AuthResult<()> {
        self.inner.delete_member(member_id).await
    }
    async fn delete_member_with_context(
        &self,
        member_id: &str,
        organization_id: &str,
        user_id: &str,
        remove_team_members: bool,
    ) -> AuthResult<()> {
        self.inner
            .delete_member_with_context(member_id, organization_id, user_id, remove_team_members)
            .await
    }
    async fn list_organization_members_page(
        &self,
        organization_id: &str,
        limit: usize,
    ) -> AuthResult<Vec<Member>> {
        self.inner
            .list_organization_members_page(organization_id, limit)
            .await
    }
    async fn list_organization_members(&self, org_id: &str) -> AuthResult<Vec<Member>> {
        self.inner.list_organization_members(org_id).await
    }
    async fn query_organization_members(
        &self,
        params: &ListOrganizationMembersParams,
    ) -> AuthResult<(Vec<Member>, usize)> {
        self.inner.query_organization_members(params).await
    }
    async fn query_organization_members_page(
        &self,
        params: &MemberPageQuery,
    ) -> AuthResult<(Vec<Member>, usize)> {
        self.inner.query_organization_members_page(params).await
    }
    async fn count_organization_members(&self, org_id: &str) -> AuthResult<i64> {
        self.inner.count_organization_members(org_id).await
    }
    async fn count_organization_owners(&self, org_id: &str) -> AuthResult<i64> {
        self.inner.count_organization_owners(org_id).await
    }
}

#[async_trait]
impl<S: AuthSchema> InvitationStore for PluginStore<S> {
    async fn create_invitation(&self, invitation: CreateInvitation) -> AuthResult<Invitation> {
        self.inner.create_invitation(invitation).await
    }
    async fn get_invitation_by_id(&self, id: &str) -> AuthResult<Option<Invitation>> {
        self.inner.get_invitation_by_id(id).await
    }
    async fn create_invitation_with_options(
        &self,
        invitation: CreateInvitation,
        options: InvitationCreateOptions,
    ) -> AuthResult<Invitation> {
        self.inner
            .create_invitation_with_options(invitation, options)
            .await
    }
    async fn pending_invitation_page(
        &self,
        org_id: &str,
        email: Option<&str>,
    ) -> AuthResult<Vec<Invitation>> {
        self.inner.pending_invitation_page(org_id, email).await
    }
    async fn update_invitation_expiry(
        &self,
        id: &str,
        expires_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Invitation> {
        self.inner.update_invitation_expiry(id, expires_at).await
    }
    async fn get_pending_invitation(
        &self,
        org_id: &str,
        email: &str,
    ) -> AuthResult<Option<Invitation>> {
        self.inner.get_pending_invitation(org_id, email).await
    }
    async fn update_invitation_status(
        &self,
        id: &str,
        status: InvitationStatus,
    ) -> AuthResult<Invitation> {
        self.inner.update_invitation_status(id, status).await
    }
    async fn update_invitation_status_if_status(
        &self,
        id: &str,
        expected: InvitationStatus,
        status: InvitationStatus,
    ) -> AuthResult<Option<Invitation>> {
        self.inner
            .update_invitation_status_if_status(id, expected, status)
            .await
    }
    async fn list_organization_invitations(&self, org_id: &str) -> AuthResult<Vec<Invitation>> {
        self.inner.list_organization_invitations(org_id).await
    }
    async fn count_pending_organization_invitations(&self, org_id: &str) -> AuthResult<i64> {
        self.inner
            .count_pending_organization_invitations(org_id)
            .await
    }
    async fn list_user_invitations(&self, email: &str) -> AuthResult<Vec<Invitation>> {
        self.inner.list_user_invitations(email).await
    }
    async fn accept_invitation_with_teams(
        &self,
        invitation_id: &str,
        user_id: &str,
        session_token: &str,
        team_limits: &[(String, Option<f64>)],
        membership_limit: Option<usize>,
    ) -> AuthResult<Option<(Invitation, Member)>> {
        self.inner
            .accept_invitation_with_teams(
                invitation_id,
                user_id,
                session_token,
                team_limits,
                membership_limit,
            )
            .await
    }
    async fn update_invitation_team_ids(
        &self,
        id: &str,
        team_ids: Option<String>,
    ) -> AuthResult<Invitation> {
        self.inner.update_invitation_team_ids(id, team_ids).await
    }
}

#[async_trait]
impl<S: AuthSchema> TwoFactorStore for PluginStore<S> {
    async fn update_two_factor(
        &self,
        id: &str,
        update: UpdateTwoFactor,
    ) -> AuthResult<Option<TwoFactor>> {
        self.inner.update_two_factor(id, update).await
    }
    async fn increment_two_factor_failure(&self, id: &str) -> AuthResult<Option<TwoFactor>> {
        self.inner.increment_two_factor_failure(id).await
    }
    async fn set_two_factor_lock_if_count_at_least(
        &self,
        id: &str,
        threshold: f64,
        until: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<TwoFactor>> {
        self.inner
            .set_two_factor_lock_if_count_at_least(id, threshold, until)
            .await
    }
    async fn clear_expired_two_factor_lock(
        &self,
        id: &str,
        now: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<TwoFactor>> {
        self.inner.clear_expired_two_factor_lock(id, now).await
    }
    async fn reset_two_factor_failures(&self, id: &str) -> AuthResult<()> {
        self.inner.reset_two_factor_failures(id).await
    }
    async fn compare_and_swap_two_factor_backup_codes(
        &self,
        id: &str,
        expected: &str,
        replacement: &str,
    ) -> AuthResult<bool> {
        self.inner
            .compare_and_swap_two_factor_backup_codes(id, expected, replacement)
            .await
    }
    async fn create_two_factor(&self, two_factor: CreateTwoFactor) -> AuthResult<TwoFactor> {
        self.inner.create_two_factor(two_factor).await
    }
    async fn get_two_factor_by_user_id(&self, user_id: &str) -> AuthResult<Option<TwoFactor>> {
        self.inner.get_two_factor_by_user_id(user_id).await
    }
    async fn update_two_factor_backup_codes(
        &self,
        user_id: &str,
        backup_codes: &str,
    ) -> AuthResult<TwoFactor> {
        self.inner
            .update_two_factor_backup_codes(user_id, backup_codes)
            .await
    }
    async fn delete_two_factor(&self, user_id: &str) -> AuthResult<()> {
        self.inner.delete_two_factor(user_id).await
    }
}

#[async_trait]
impl<S: AuthSchema> ApiKeyStore for PluginStore<S> {
    async fn consume_api_key_usage_from_snapshot(
        &self,
        observed: &ApiKey,
        global_rate_limit_enabled: bool,
    ) -> AuthResult<ConsumeApiKeyResult> {
        self.inner
            .consume_api_key_usage_from_snapshot(observed, global_rate_limit_enabled)
            .await
    }
    async fn create_api_key(&self, input: CreateApiKey) -> AuthResult<ApiKey> {
        self.inner.create_api_key(input).await
    }
    async fn get_api_key_by_id(&self, id: &str) -> AuthResult<Option<ApiKey>> {
        self.inner.get_api_key_by_id(id).await
    }
    async fn get_api_key_by_hash(&self, hash: &str) -> AuthResult<Option<ApiKey>> {
        self.inner.get_api_key_by_hash(hash).await
    }
    async fn list_api_keys_by_reference(&self, reference_id: &str) -> AuthResult<Vec<ApiKey>> {
        self.inner.list_api_keys_by_reference(reference_id).await
    }
    async fn update_api_key(&self, id: &str, update: UpdateApiKey) -> AuthResult<ApiKey> {
        self.inner.update_api_key(id, update).await
    }
    async fn delete_api_key(&self, id: &str) -> AuthResult<()> {
        self.inner.delete_api_key(id).await
    }
    async fn delete_expired_api_keys(&self) -> AuthResult<usize> {
        self.inner.delete_expired_api_keys().await
    }
    async fn consume_api_key_usage(
        &self,
        id: &str,
        global_rate_limit_enabled: bool,
    ) -> AuthResult<ConsumeApiKeyResult> {
        self.inner
            .consume_api_key_usage(id, global_rate_limit_enabled)
            .await
    }
}

#[async_trait]
impl<S: AuthSchema> PasskeyStore for PluginStore<S> {
    async fn create_passkey(&self, input: CreatePasskey) -> AuthResult<Passkey> {
        self.inner.create_passkey(input).await
    }
    async fn get_passkey_by_id(&self, id: &str) -> AuthResult<Option<Passkey>> {
        self.inner.get_passkey_by_id(id).await
    }
    async fn get_passkey_by_credential_id(
        &self,
        credential_id: &str,
    ) -> AuthResult<Option<Passkey>> {
        self.inner.get_passkey_by_credential_id(credential_id).await
    }
    async fn list_passkeys_by_user(&self, user_id: &str) -> AuthResult<Vec<Passkey>> {
        self.inner.list_passkeys_by_user(user_id).await
    }
    async fn update_passkey_authentication(
        &self,
        id: &str,
        update: UpdatePasskeyAuthentication,
    ) -> AuthResult<Option<Passkey>> {
        self.inner.update_passkey_authentication(id, update).await
    }
    async fn update_passkey_name(&self, id: &str, name: &str) -> AuthResult<Passkey> {
        self.inner.update_passkey_name(id, name).await
    }
    async fn delete_passkey(&self, id: &str) -> AuthResult<()> {
        self.inner.delete_passkey(id).await
    }
}

#[async_trait]
impl<S: AuthSchema> DeviceCodeStore for PluginStore<S> {
    async fn create_device_code(&self, input: CreateDeviceCode) -> AuthResult<DeviceCode> {
        self.inner.create_device_code(input).await
    }
    async fn create_device_code_with_fields(
        &self,
        input: CreateDeviceCode,
        fields: serde_json::Map<String, serde_json::Value>,
    ) -> AuthResult<DeviceCode> {
        self.inner
            .create_device_code_with_fields(input, fields)
            .await
    }
    async fn device_code_fields(
        &self,
        id: &str,
    ) -> AuthResult<serde_json::Map<String, serde_json::Value>> {
        self.inner.device_code_fields(id).await
    }
    async fn consume_device_code(
        &self,
        id: &str,
        status: &str,
        ownership: &serde_json::Map<String, serde_json::Value>,
    ) -> AuthResult<Option<DeviceCode>> {
        self.inner.consume_device_code(id, status, ownership).await
    }
    async fn get_device_code_by_device_code(
        &self,
        device_code: &str,
    ) -> AuthResult<Option<DeviceCode>> {
        self.inner.get_device_code_by_device_code(device_code).await
    }
    async fn get_device_code_by_user_code(
        &self,
        user_code: &str,
    ) -> AuthResult<Option<DeviceCode>> {
        self.inner.get_device_code_by_user_code(user_code).await
    }
    async fn update_device_code(
        &self,
        id: &str,
        update: UpdateDeviceCode,
    ) -> AuthResult<DeviceCode> {
        self.inner.update_device_code(id, update).await
    }
    async fn update_device_code_if_status(
        &self,
        id: &str,
        current_status: &str,
        update: UpdateDeviceCode,
    ) -> AuthResult<bool> {
        self.inner
            .update_device_code_if_status(id, current_status, update)
            .await
    }
    async fn claim_device_code(&self, id: &str, user_id: &str) -> AuthResult<bool> {
        self.inner.claim_device_code(id, user_id).await
    }
    async fn delete_device_code(&self, id: &str) -> AuthResult<()> {
        self.inner.delete_device_code(id).await
    }
    async fn delete_device_code_if_status(&self, id: &str, status: &str) -> AuthResult<bool> {
        self.inner.delete_device_code_if_status(id, status).await
    }
}

#[async_trait]
impl<S: AuthSchema> TeamStore for PluginStore<S> {
    async fn create_team(&self, data: CreateTeam) -> AuthResult<Team> {
        self.inner.create_team(data).await
    }
    async fn get_team(
        &self,
        organization_id: Option<&str>,
        team_id: &str,
    ) -> AuthResult<Option<Team>> {
        self.inner.get_team(organization_id, team_id).await
    }
    async fn list_teams(&self, organization_id: &str) -> AuthResult<Vec<Team>> {
        self.inner.list_teams(organization_id).await
    }
    async fn update_team(
        &self,
        organization_id: &str,
        team_id: &str,
        update: UpdateTeam,
    ) -> AuthResult<Team> {
        self.inner
            .update_team(organization_id, team_id, update)
            .await
    }
    async fn delete_team(&self, organization_id: &str, team_id: &str) -> AuthResult<bool> {
        self.inner.delete_team(organization_id, team_id).await
    }
    async fn get_team_member(
        &self,
        team_id: &str,
        user_id: &str,
    ) -> AuthResult<Option<TeamMember>> {
        self.inner.get_team_member(team_id, user_id).await
    }
    async fn add_team_member(
        &self,
        team_id: &str,
        user_id: &str,
        maximum: Option<f64>,
    ) -> AuthResult<AddTeamMemberResult> {
        self.inner.add_team_member(team_id, user_id, maximum).await
    }
    async fn remove_team_member(&self, team_id: &str, user_id: &str) -> AuthResult<usize> {
        self.inner.remove_team_member(team_id, user_id).await
    }
    async fn list_team_members(&self, team_id: &str) -> AuthResult<Vec<TeamMember>> {
        self.inner.list_team_members(team_id).await
    }
    async fn list_user_teams(&self, user_id: &str) -> AuthResult<Vec<Team>> {
        self.inner.list_user_teams(user_id).await
    }
}

#[async_trait]
impl<S: AuthSchema> OrganizationRoleStore for PluginStore<S> {
    async fn create_organization_role(
        &self,
        data: CreateOrganizationRole,
    ) -> AuthResult<OrganizationRole> {
        self.inner.create_organization_role(data).await
    }
    async fn get_organization_role(
        &self,
        organization_id: &str,
        selector: &OrganizationRoleSelector,
    ) -> AuthResult<Option<OrganizationRole>> {
        self.inner
            .get_organization_role(organization_id, selector)
            .await
    }
    async fn list_organization_roles(
        &self,
        organization_id: &str,
    ) -> AuthResult<Vec<OrganizationRole>> {
        self.inner.list_organization_roles(organization_id).await
    }
    async fn count_organization_roles(&self, organization_id: &str) -> AuthResult<usize> {
        self.inner.count_organization_roles(organization_id).await
    }
    async fn has_organization_role_members(
        &self,
        organization_id: &str,
        role: &str,
    ) -> AuthResult<bool> {
        self.inner
            .has_organization_role_members(organization_id, role)
            .await
    }
    async fn update_organization_role(
        &self,
        organization_id: &str,
        selector: &OrganizationRoleSelector,
        update: UpdateOrganizationRole,
    ) -> AuthResult<OrganizationRole> {
        self.inner
            .update_organization_role(organization_id, selector, update)
            .await
    }
    async fn delete_organization_role(
        &self,
        organization_id: &str,
        selector: &OrganizationRoleSelector,
    ) -> AuthResult<bool> {
        self.inner
            .delete_organization_role(organization_id, selector)
            .await
    }
}

#[async_trait]
impl<S: AuthSchema> JwkStore for PluginStore<S> {
    async fn list_jwks(&self) -> AuthResult<Vec<Jwk>> {
        self.inner.list_jwks().await
    }
    async fn get_jwk_by_id(&self, id: &str) -> AuthResult<Option<Jwk>> {
        self.inner.get_jwk_by_id(id).await
    }
    async fn create_jwk(&self, data: CreateJwk) -> AuthResult<Jwk> {
        self.inner.create_jwk(data).await
    }
}

#[async_trait]
impl<S: AuthSchema> WalletAddressStore for PluginStore<S> {
    async fn get_wallet_address(
        &self,
        address: &str,
        chain_id: Option<f64>,
    ) -> AuthResult<Option<WalletAddress>> {
        self.inner.get_wallet_address(address, chain_id).await
    }
    async fn create_wallet_address(&self, data: CreateWalletAddress) -> AuthResult<WalletAddress> {
        self.inner.create_wallet_address(data).await
    }
}

#[async_trait::async_trait]
impl<S: AuthSchema> crate::store::OAuthClientStore for PluginStore<S> {
    async fn store_oauth_refresh_replay(&self, id: &str, ciphertext: &str) -> AuthResult<()> {
        self.inner.store_oauth_refresh_replay(id, ciphertext).await
    }
    async fn claim_oauth_refresh_rotation(
        &self,
        token: &str,
        at: chrono::DateTime<chrono::Utc>,
        replay_expires: Option<chrono::DateTime<chrono::Utc>>,
    ) -> AuthResult<bool> {
        self.inner
            .claim_oauth_refresh_rotation(token, at, replay_expires)
            .await
    }

    async fn list_oauth_tokens_for_session(
        &self,
        kind: crate::store::OAuthTokenKind,
        session_id: &str,
    ) -> AuthResult<Vec<crate::store::OAuthToken>> {
        self.inner
            .list_oauth_tokens_for_session(kind, session_id)
            .await
    }
    async fn mark_oauth_token_revoked(
        &self,
        kind: crate::store::OAuthTokenKind,
        id: &str,
        at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<()> {
        self.inner.mark_oauth_token_revoked(kind, id, at).await
    }

    async fn delete_oauth_token(
        &self,
        kind: crate::store::OAuthTokenKind,
        token: &str,
    ) -> AuthResult<()> {
        self.inner.delete_oauth_token(kind, token).await
    }
    async fn revoke_oauth_refresh_token(
        &self,
        token: &str,
        revoked_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<bool> {
        self.inner
            .revoke_oauth_refresh_token(token, revoked_at)
            .await
    }
    async fn delete_oauth_access_tokens_for_refresh(&self, refresh_id: &str) -> AuthResult<()> {
        self.inner
            .delete_oauth_access_tokens_for_refresh(refresh_id)
            .await
    }
    async fn delete_oauth_refresh_family(&self, client_id: &str, user_id: &str) -> AuthResult<()> {
        self.inner
            .delete_oauth_refresh_family(client_id, user_id)
            .await
    }
    async fn create_oauth_token(
        &self,
        kind: crate::store::OAuthTokenKind,
        data: crate::store::CreateOAuthToken,
    ) -> AuthResult<crate::store::OAuthToken> {
        self.inner.create_oauth_token(kind, data).await
    }
    async fn get_oauth_token(
        &self,
        kind: crate::store::OAuthTokenKind,
        token: &str,
    ) -> AuthResult<Option<crate::store::OAuthToken>> {
        self.inner.get_oauth_token(kind, token).await
    }
    async fn delete_oauth_tokens_for_code(&self, code: &str) -> AuthResult<()> {
        self.inner.delete_oauth_tokens_for_code(code).await
    }
    async fn delete_oauth_client_resource(
        &self,
        client_id: &str,
        resource_id: &str,
    ) -> AuthResult<()> {
        self.inner
            .delete_oauth_client_resource(client_id, resource_id)
            .await
    }
    async fn create_oauth_client_resource(
        &self,
        data: crate::store::CreateOAuthClientResource,
    ) -> AuthResult<crate::store::OAuthClientResource> {
        self.inner.create_oauth_client_resource(data).await
    }
    async fn delete_oauth_resource(&self, identifier: &str) -> AuthResult<()> {
        self.inner.delete_oauth_resource(identifier).await
    }
    async fn update_oauth_resource(
        &self,
        identifier: &str,
        metadata: serde_json::Value,
        updated_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<crate::store::OAuthResource>> {
        self.inner
            .update_oauth_resource(identifier, metadata, updated_at)
            .await
    }
    async fn list_oauth_resources(&self) -> AuthResult<Vec<crate::store::OAuthResource>> {
        self.inner.list_oauth_resources().await
    }
    async fn list_oauth_client_resources(
        &self,
        client_id: &str,
    ) -> AuthResult<Vec<crate::store::OAuthClientResource>> {
        self.inner.list_oauth_client_resources(client_id).await
    }
    async fn create_oauth_resource(
        &self,
        data: crate::store::CreateOAuthResource,
    ) -> AuthResult<crate::store::OAuthResource> {
        self.inner.create_oauth_resource(data).await
    }
    async fn get_oauth_resource(
        &self,
        identifier: &str,
    ) -> AuthResult<Option<crate::store::OAuthResource>> {
        self.inner.get_oauth_resource(identifier).await
    }
    async fn delete_oauth_consent(&self, id: &str) -> AuthResult<()> {
        self.inner.delete_oauth_consent(id).await
    }
    async fn get_oauth_consent(&self, id: &str) -> AuthResult<Option<crate::store::OAuthConsent>> {
        self.inner.get_oauth_consent(id).await
    }
    async fn create_oauth_consent(
        &self,
        data: crate::store::CreateOAuthConsent,
    ) -> AuthResult<crate::store::OAuthConsent> {
        self.inner.create_oauth_consent(data).await
    }
    async fn list_oauth_consents_by_user(
        &self,
        user_id: &str,
    ) -> AuthResult<Vec<crate::store::OAuthConsent>> {
        self.inner.list_oauth_consents_by_user(user_id).await
    }
    async fn update_oauth_consent_metadata(
        &self,
        id: &str,
        metadata: serde_json::Value,
        updated_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<crate::store::OAuthConsent>> {
        self.inner
            .update_oauth_consent_metadata(id, metadata, updated_at)
            .await
    }
    async fn create_oauth_client(
        &self,
        data: crate::store::CreateOAuthClient,
    ) -> AuthResult<crate::store::OAuthClient> {
        self.inner.create_oauth_client(data).await
    }
    async fn get_oauth_client(
        &self,
        client_id: &str,
    ) -> AuthResult<Option<crate::store::OAuthClient>> {
        self.inner.get_oauth_client(client_id).await
    }
    async fn list_oauth_clients_by_user(
        &self,
        user_id: &str,
    ) -> AuthResult<Vec<crate::store::OAuthClient>> {
        self.inner.list_oauth_clients_by_user(user_id).await
    }
    async fn delete_oauth_client(&self, client_id: &str) -> AuthResult<()> {
        self.inner.delete_oauth_client(client_id).await
    }
    async fn update_oauth_client_secret(
        &self,
        client_id: &str,
        secret: String,
        updated_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<crate::store::OAuthClient>> {
        self.inner
            .update_oauth_client_secret(client_id, secret, updated_at)
            .await
    }
    async fn update_oauth_client_metadata(
        &self,
        client_id: &str,
        metadata: serde_json::Value,
        updated_at: chrono::DateTime<chrono::Utc>,
    ) -> AuthResult<Option<crate::store::OAuthClient>> {
        self.inner
            .update_oauth_client_metadata(client_id, metadata, updated_at)
            .await
    }
}

#[async_trait]
impl<S: AuthSchema> crate::store::SsoProviderStore for PluginStore<S> {
    async fn list_sso_providers(&self) -> AuthResult<Vec<crate::store::SsoProvider>> {
        self.inner.list_sso_providers().await
    }
    async fn create_sso_provider(
        &self,
        provider: crate::store::SsoProvider,
    ) -> AuthResult<crate::store::SsoProvider> {
        self.inner.create_sso_provider(provider).await
    }
    async fn get_sso_provider(
        &self,
        provider_id: &str,
    ) -> AuthResult<Option<crate::store::SsoProvider>> {
        self.inner.get_sso_provider(provider_id).await
    }
    async fn list_sso_providers_by_user(
        &self,
        user_id: &str,
    ) -> AuthResult<Vec<crate::store::SsoProvider>> {
        self.inner.list_sso_providers_by_user(user_id).await
    }
}