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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
#![deny(warnings)]
#![warn(unused_extern_crates)]
#![deny(clippy::todo)]
#![deny(clippy::unimplemented)]
#![deny(clippy::unwrap_used)]
#![deny(clippy::expect_used)]
#![deny(clippy::panic)]
#![deny(clippy::unreachable)]
#![deny(clippy::await_holding_lock)]
#![deny(clippy::needless_pass_by_value)]
#![deny(clippy::trivially_copy_pass_by_ref)]
#[macro_use]
extern crate tracing;
use serde::Deserialize;
use serde_json::error::Error as SerdeJsonError;
use std::collections::BTreeSet as Set;
use std::fs::{metadata, File, Metadata};
use std::io::ErrorKind;
use std::io::Read;
#[cfg(target_family = "unix")]
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use std::time::Duration;
use tokio::sync::RwLock;
use url::Url;
use uuid::Uuid;
pub use reqwest::StatusCode;
use webauthn_rs::proto::{
CreationChallengeResponse, PublicKeyCredential, RegisterPublicKeyCredential,
RequestChallengeResponse,
};
use kanidm_proto::v1::*;
pub mod asynchronous;
use crate::asynchronous::KanidmAsyncClient;
pub const APPLICATION_JSON: &str = "application/json";
pub const KOPID: &str = "X-KANIDM-OPID";
pub const KSESSIONID: &str = "X-KANIDM-AUTH-SESSION-ID";
#[derive(Debug)]
pub enum ClientError {
Unauthorized,
Http(reqwest::StatusCode, Option<OperationError>, String),
Transport(reqwest::Error),
AuthenticationFailed,
EmptyResponse,
TotpVerifyFailed(Uuid, TotpSecret),
TotpInvalidSha1(Uuid),
JsonDecode(reqwest::Error, String),
JsonEncode(SerdeJsonError),
SystemError,
}
#[derive(Debug, Deserialize)]
struct KanidmClientConfig {
uri: Option<String>,
verify_ca: Option<bool>,
verify_hostnames: Option<bool>,
ca_path: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct KanidmClientBuilder {
address: Option<String>,
verify_ca: bool,
verify_hostnames: bool,
ca: Option<reqwest::Certificate>,
connect_timeout: Option<u64>,
use_system_proxies: bool,
}
fn read_file_metadata<P: AsRef<Path>>(path: &P) -> Result<Metadata, ()> {
metadata(path).map_err(|e| {
error!(
"Unable to read metadata for {} - {:?}",
path.as_ref().to_str().unwrap_or("Alert: invalid path"),
e
);
})
}
impl KanidmClientBuilder {
pub fn new() -> Self {
KanidmClientBuilder {
address: None,
verify_ca: true,
verify_hostnames: true,
ca: None,
connect_timeout: None,
use_system_proxies: true,
}
}
fn parse_certificate(ca_path: &str) -> Result<reqwest::Certificate, ()> {
let mut buf = Vec::new();
#[cfg(target_family = "windows")]
warn!("File metadata checks on Windows aren't supported right now, this could be a security risk.");
#[cfg(target_family = "unix")]
{
let path = Path::new(ca_path);
let ca_meta = read_file_metadata(&path)?;
if !ca_meta.permissions().readonly() {
warn!("permissions on {} may not be secure. Should be readonly to running uid. This could be a security risk ...", ca_path);
}
#[cfg(target_family = "unix")]
if ca_meta.uid() != 0 || ca_meta.gid() != 0 {
warn!(
"{} should be owned be root:root to prevent tampering",
ca_path
);
}
}
let mut f = File::open(ca_path).map_err(|_| ())?;
f.read_to_end(&mut buf).map_err(|_| ())?;
reqwest::Certificate::from_pem(&buf).map_err(|_| ())
}
fn apply_config_options(self, kcc: KanidmClientConfig) -> Result<Self, ()> {
let KanidmClientBuilder {
address,
verify_ca,
verify_hostnames,
ca,
connect_timeout,
use_system_proxies,
} = self;
let address = match kcc.uri {
Some(uri) => Some(uri),
None => {
debug!("No URI in config supplied to apply_config_options");
address
}
};
let verify_ca = kcc.verify_ca.unwrap_or(verify_ca);
let verify_hostnames = kcc.verify_hostnames.unwrap_or(verify_hostnames);
let ca = match kcc.ca_path {
Some(ca_path) => Some(Self::parse_certificate(ca_path.as_str())?),
None => ca,
};
Ok(KanidmClientBuilder {
address,
verify_ca,
verify_hostnames,
ca,
connect_timeout,
use_system_proxies,
})
}
#[allow(clippy::result_unit_err)]
pub fn read_options_from_optional_config<P: AsRef<Path> + std::fmt::Debug>(
self,
config_path: P,
) -> Result<Self, ()> {
debug!("Attempting to load configuration from {:#?}", &config_path);
let mut f = match File::open(&config_path) {
Ok(f) => {
debug!("Successfully opened configuration file {:#?}", &config_path);
f
}
Err(e) => {
match e.kind() {
ErrorKind::NotFound => {
debug!(
"Configuration file {:#?} not found, skipping.",
&config_path
);
}
ErrorKind::PermissionDenied => {
warn!(
"Permission denied loading configuration file {:#?}, skipping.",
&config_path
);
}
_ => {
debug!(
"Unable to open config file {:#?} [{:?}], skipping ...",
&config_path, e
);
}
};
return Ok(self);
}
};
let mut contents = String::new();
f.read_to_string(&mut contents)
.map_err(|e| eprintln!("{:?}", e))?;
let config: KanidmClientConfig =
toml::from_str(contents.as_str()).map_err(|e| eprintln!("{:?}", e))?;
self.apply_config_options(config)
}
pub fn address(self, address: String) -> Self {
KanidmClientBuilder {
address: Some(address),
verify_ca: self.verify_ca,
verify_hostnames: self.verify_hostnames,
ca: self.ca,
connect_timeout: self.connect_timeout,
use_system_proxies: self.use_system_proxies,
}
}
pub fn danger_accept_invalid_hostnames(self, accept_invalid_hostnames: bool) -> Self {
KanidmClientBuilder {
address: self.address,
verify_ca: self.verify_ca,
verify_hostnames: !accept_invalid_hostnames,
ca: self.ca,
connect_timeout: self.connect_timeout,
use_system_proxies: self.use_system_proxies,
}
}
pub fn danger_accept_invalid_certs(self, accept_invalid_certs: bool) -> Self {
KanidmClientBuilder {
address: self.address,
verify_ca: !accept_invalid_certs,
verify_hostnames: self.verify_hostnames,
ca: self.ca,
connect_timeout: self.connect_timeout,
use_system_proxies: self.use_system_proxies,
}
}
pub fn connect_timeout(self, secs: u64) -> Self {
KanidmClientBuilder {
address: self.address,
verify_ca: self.verify_ca,
verify_hostnames: self.verify_hostnames,
ca: self.ca,
connect_timeout: Some(secs),
use_system_proxies: self.use_system_proxies,
}
}
pub fn no_proxy(self) -> Self {
KanidmClientBuilder {
address: self.address,
verify_ca: self.verify_ca,
verify_hostnames: self.verify_hostnames,
ca: self.ca,
connect_timeout: self.connect_timeout,
use_system_proxies: false,
}
}
#[allow(clippy::result_unit_err)]
pub fn add_root_certificate_filepath(self, ca_path: &str) -> Result<Self, ()> {
let ca = Self::parse_certificate(ca_path)?;
Ok(KanidmClientBuilder {
address: self.address,
verify_ca: self.verify_ca,
verify_hostnames: self.verify_hostnames,
ca: Some(ca),
connect_timeout: self.connect_timeout,
use_system_proxies: self.use_system_proxies,
})
}
fn display_warnings(&self, address: &str) {
if !self.verify_ca {
warn!("verify_ca set to false in client configuration - this may allow network interception of passwords!");
}
if !self.verify_hostnames {
warn!(
"verify_hostnames set to false in client configuration - this may allow network interception of passwords!"
);
}
if !address.starts_with("https://") {
warn!("Address does not start with 'https://' - this may allow network interception of passwords!");
}
}
pub fn user_agent() -> &'static str {
static APP_USER_AGENT: &str =
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),);
APP_USER_AGENT
}
pub fn build(self) -> Result<KanidmClient, reqwest::Error> {
self.build_async().map(|asclient| KanidmClient { asclient })
}
pub fn build_async(self) -> Result<KanidmAsyncClient, reqwest::Error> {
let address = match &self.address {
Some(a) => a.clone(),
None => {
error!("Configuration option 'uri' missing from client configuration, cannot continue client startup without specifying a server to connect to. 🤔");
std::process::exit(1);
}
};
self.display_warnings(address.as_str());
let client_builder = reqwest::Client::builder()
.user_agent(KanidmClientBuilder::user_agent())
.danger_accept_invalid_hostnames(!self.verify_hostnames)
.danger_accept_invalid_certs(!self.verify_ca);
let client_builder = match self.use_system_proxies {
true => client_builder,
false => client_builder.no_proxy(),
};
let client_builder = match &self.ca {
Some(cert) => client_builder.add_root_certificate(cert.clone()),
None => client_builder,
};
let client_builder = match &self.connect_timeout {
Some(secs) => client_builder
.connect_timeout(Duration::from_secs(*secs))
.timeout(Duration::from_secs(*secs)),
None => client_builder,
};
let client = client_builder.build()?;
#[allow(clippy::expect_used)]
let uri = Url::parse(&address).expect("can not fail");
#[allow(clippy::expect_used)]
let origin = uri.origin().unicode_serialization();
Ok(KanidmAsyncClient {
client,
addr: address,
builder: self,
bearer_token: RwLock::new(None),
origin,
auth_session_id: RwLock::new(None),
})
}
}
#[derive(Debug)]
pub struct KanidmClient {
asclient: KanidmAsyncClient,
}
#[allow(clippy::expect_used)]
fn tokio_block_on<R, F>(f: F) -> R
where
F: std::future::Future + std::future::Future<Output = R>,
{
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to start tokio");
rt.block_on(f)
}
impl KanidmClient {
pub fn get_origin(&self) -> &str {
self.asclient.get_origin()
}
pub fn get_url(&self) -> &str {
self.asclient.get_url()
}
pub fn new_session(&self) -> Result<Self, reqwest::Error> {
self.asclient
.new_session()
.map(|asclient| KanidmClient { asclient })
}
pub fn set_token(&self, new_token: String) {
tokio_block_on(self.asclient.set_token(new_token));
}
pub fn get_token(&self) -> Option<String> {
tokio_block_on(self.asclient.get_token())
}
pub fn logout(&self) {
tokio_block_on(self.asclient.logout())
}
pub fn whoami(&self) -> Result<Option<(Entry, UserAuthToken)>, ClientError> {
tokio_block_on(self.asclient.whoami())
}
pub fn auth_step_init(&self, ident: &str) -> Result<Set<AuthMech>, ClientError> {
tokio_block_on(self.asclient.auth_step_init(ident))
}
pub fn auth_step_begin(&self, mech: AuthMech) -> Result<Vec<AuthAllowed>, ClientError> {
tokio_block_on(self.asclient.auth_step_begin(mech))
}
pub fn auth_step_anonymous(&self) -> Result<AuthResponse, ClientError> {
tokio_block_on(self.asclient.auth_step_anonymous())
}
pub fn auth_step_password(&self, password: &str) -> Result<AuthResponse, ClientError> {
tokio_block_on(self.asclient.auth_step_password(password))
}
pub fn auth_step_backup_code(&self, backup_code: &str) -> Result<AuthResponse, ClientError> {
tokio_block_on(self.asclient.auth_step_backup_code(backup_code))
}
pub fn auth_step_totp(&self, totp: u32) -> Result<AuthResponse, ClientError> {
tokio_block_on(self.asclient.auth_step_totp(totp))
}
pub fn auth_step_webauthn_complete(
&self,
pkc: PublicKeyCredential,
) -> Result<AuthResponse, ClientError> {
tokio_block_on(self.asclient.auth_step_webauthn_complete(pkc))
}
pub fn auth_anonymous(&self) -> Result<(), ClientError> {
tokio_block_on(self.asclient.auth_anonymous())
}
pub fn auth_simple_password(&self, ident: &str, password: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.auth_simple_password(ident, password))
}
pub fn auth_password_totp(
&self,
ident: &str,
password: &str,
totp: u32,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.auth_password_totp(ident, password, totp))
}
pub fn auth_password_backup_code(
&self,
ident: &str,
password: &str,
backup_code: &str,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.auth_password_backup_code(ident, password, backup_code),
)
}
pub fn auth_webauthn_begin(
&self,
ident: &str,
) -> Result<RequestChallengeResponse, ClientError> {
tokio_block_on(self.asclient.auth_webauthn_begin(ident))
}
pub fn auth_valid(&self) -> Result<(), ClientError> {
tokio_block_on(self.asclient.auth_valid())
}
pub fn auth_webauthn_complete(&self, pkc: PublicKeyCredential) -> Result<(), ClientError> {
tokio_block_on(self.asclient.auth_webauthn_complete(pkc))
}
pub fn search(&self, filter: Filter) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.search(filter))
}
pub fn create(&self, entries: Vec<Entry>) -> Result<(), ClientError> {
tokio_block_on(self.asclient.create(entries))
}
pub fn modify(&self, filter: Filter, modlist: ModifyList) -> Result<(), ClientError> {
tokio_block_on(self.asclient.modify(filter, modlist))
}
pub fn delete(&self, filter: Filter) -> Result<(), ClientError> {
tokio_block_on(self.asclient.delete(filter))
}
pub fn idm_group_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_group_list())
}
pub fn idm_group_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_group_get(id))
}
pub fn idm_group_get_members(&self, id: &str) -> Result<Option<Vec<String>>, ClientError> {
tokio_block_on(self.asclient.idm_group_get_members(id))
}
pub fn idm_group_set_members(&self, id: &str, members: &[&str]) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_set_members(id, members))
}
pub fn idm_group_add_members(&self, id: &str, members: &[&str]) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_add_members(id, members))
}
pub fn idm_group_remove_members(
&self,
group: &str,
members: &[&str],
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_remove_members(group, members))
}
pub fn idm_group_purge_members(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_purge_members(id))
}
pub fn idm_group_unix_token_get(&self, id: &str) -> Result<UnixGroupToken, ClientError> {
tokio_block_on(self.asclient.idm_group_unix_token_get(id))
}
pub fn idm_group_unix_extend(
&self,
id: &str,
gidnumber: Option<u32>,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_unix_extend(id, gidnumber))
}
pub fn idm_group_delete(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_delete(id))
}
pub fn idm_group_create(&self, name: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_group_create(name))
}
pub fn idm_account_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_account_list())
}
pub fn idm_account_create(&self, name: &str, dn: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_create(name, dn))
}
pub fn idm_account_set_password(&self, cleartext: String) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_set_password(cleartext))
}
pub fn idm_account_set_displayname(&self, id: &str, dn: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_set_displayname(id, dn))
}
pub fn idm_account_delete(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_delete(id))
}
pub fn idm_account_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_account_get(id))
}
pub fn idm_account_get_attr(
&self,
id: &str,
attr: &str,
) -> Result<Option<Vec<String>>, ClientError> {
tokio_block_on(self.asclient.idm_account_get_attr(id, attr))
}
pub fn idm_account_primary_credential_set_password(
&self,
id: &str,
pw: &str,
) -> Result<SetCredentialResponse, ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_set_password(id, pw),
)
}
pub fn idm_account_purge_attr(&self, id: &str, attr: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_purge_attr(id, attr))
}
pub fn idm_account_add_attr(
&self,
id: &str,
attr: &str,
values: &[&str],
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_add_attr(id, attr, values))
}
pub fn idm_account_set_attr(
&self,
id: &str,
attr: &str,
values: &[&str],
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_set_attr(id, attr, values))
}
pub fn idm_account_primary_credential_import_password(
&self,
id: &str,
pw: &str,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_import_password(id, pw),
)
}
pub fn idm_account_primary_credential_set_generated(
&self,
id: &str,
) -> Result<String, ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_set_generated(id),
)
}
pub fn idm_account_primary_credential_generate_totp(
&self,
id: &str,
) -> Result<(Uuid, TotpSecret), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_generate_totp(id),
)
}
pub fn idm_account_primary_credential_verify_totp(
&self,
id: &str,
otp: u32,
session: Uuid,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_verify_totp(id, otp, session),
)
}
pub fn idm_account_primary_credential_accept_sha1_totp(
&self,
id: &str,
session: Uuid,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_accept_sha1_totp(id, session),
)
}
pub fn idm_account_primary_credential_remove_totp(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_primary_credential_remove_totp(id))
}
pub fn idm_account_primary_credential_register_webauthn(
&self,
id: &str,
label: &str,
) -> Result<(Uuid, CreationChallengeResponse), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_register_webauthn(id, label),
)
}
pub fn idm_account_primary_credential_complete_webuthn_registration(
&self,
id: &str,
rego: RegisterPublicKeyCredential,
session: Uuid,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_complete_webuthn_registration(id, rego, session),
)
}
pub fn idm_account_primary_credential_remove_webauthn(
&self,
id: &str,
label: &str,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_remove_webauthn(id, label),
)
}
pub fn idm_account_primary_credential_generate_backup_code(
&self,
id: &str,
) -> Result<Vec<String>, ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_generate_backup_code(id),
)
}
pub fn idm_account_primary_credential_remove_backup_code(
&self,
id: &str,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_account_primary_credential_remove_backup_code(id),
)
}
pub fn idm_account_get_credential_status(
&self,
id: &str,
) -> Result<CredentialStatus, ClientError> {
tokio_block_on(self.asclient.idm_account_get_credential_status(id))
}
pub fn idm_account_radius_credential_get(
&self,
id: &str,
) -> Result<Option<String>, ClientError> {
tokio_block_on(self.asclient.idm_account_radius_credential_get(id))
}
pub fn idm_account_radius_credential_regenerate(
&self,
id: &str,
) -> Result<String, ClientError> {
tokio_block_on(self.asclient.idm_account_radius_credential_regenerate(id))
}
pub fn idm_account_radius_credential_delete(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_radius_credential_delete(id))
}
pub fn idm_account_radius_token_get(&self, id: &str) -> Result<RadiusAuthToken, ClientError> {
tokio_block_on(self.asclient.idm_account_radius_token_get(id))
}
pub fn idm_account_unix_extend(
&self,
id: &str,
gidnumber: Option<u32>,
shell: Option<&str>,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_unix_extend(id, gidnumber, shell))
}
pub fn idm_account_unix_token_get(&self, id: &str) -> Result<UnixUserToken, ClientError> {
tokio_block_on(self.asclient.idm_account_unix_token_get(id))
}
pub fn idm_account_unix_cred_put(&self, id: &str, cred: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_unix_cred_put(id, cred))
}
pub fn idm_account_unix_cred_delete(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_unix_cred_delete(id))
}
pub fn idm_account_unix_cred_verify(
&self,
id: &str,
cred: &str,
) -> Result<Option<UnixUserToken>, ClientError> {
tokio_block_on(self.asclient.idm_account_unix_cred_verify(id, cred))
}
pub fn idm_account_get_ssh_pubkeys(&self, id: &str) -> Result<Vec<String>, ClientError> {
tokio_block_on(self.asclient.idm_account_get_ssh_pubkeys(id))
}
pub fn idm_account_post_ssh_pubkey(
&self,
id: &str,
tag: &str,
pubkey: &str,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_post_ssh_pubkey(id, tag, pubkey))
}
pub fn idm_account_person_extend(
&self,
id: &str,
mail: Option<&[String]>,
legalname: Option<&str>,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_person_extend(id, mail, legalname))
}
pub fn idm_account_get_ssh_pubkey(
&self,
id: &str,
tag: &str,
) -> Result<Option<String>, ClientError> {
tokio_block_on(self.asclient.idm_account_get_ssh_pubkey(id, tag))
}
pub fn idm_account_delete_ssh_pubkey(&self, id: &str, tag: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_account_delete_ssh_pubkey(id, tag))
}
pub fn idm_domain_get(&self) -> Result<Entry, ClientError> {
tokio_block_on(self.asclient.idm_domain_get())
}
pub fn idm_domain_get_ssid(&self) -> Result<String, ClientError> {
tokio_block_on(self.asclient.idm_domain_get_ssid())
}
pub fn idm_domain_set_ssid(&self, ssid: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_domain_set_ssid(ssid))
}
pub fn idm_domain_reset_token_key(&self) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_domain_reset_token_key())
}
pub fn idm_schema_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_schema_list())
}
pub fn idm_schema_attributetype_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_schema_attributetype_list())
}
pub fn idm_schema_attributetype_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_schema_attributetype_get(id))
}
pub fn idm_schema_classtype_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_schema_classtype_list())
}
pub fn idm_schema_classtype_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_schema_classtype_get(id))
}
pub fn idm_oauth2_rs_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_list())
}
pub fn idm_oauth2_rs_basic_create(
&self,
name: &str,
displayname: &str,
origin: &str,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_oauth2_rs_basic_create(name, displayname, origin),
)
}
pub fn idm_oauth2_rs_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_get(id))
}
#[allow(clippy::too_many_arguments)]
pub fn idm_oauth2_rs_update(
&self,
id: &str,
name: Option<&str>,
displayname: Option<&str>,
origin: Option<&str>,
scopes: Option<Vec<&str>>,
reset_secret: bool,
reset_token_key: bool,
reset_sign_key: bool,
) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_update(
id,
name,
displayname,
origin,
scopes,
reset_secret,
reset_token_key,
reset_sign_key,
))
}
pub fn idm_oauth2_rs_create_scope_map(
&self,
id: &str,
group: &str,
scopes: Vec<&str>,
) -> Result<(), ClientError> {
tokio_block_on(
self.asclient
.idm_oauth2_rs_create_scope_map(id, group, scopes),
)
}
pub fn idm_oauth2_rs_delete_scope_map(&self, id: &str, group: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_delete_scope_map(id, group))
}
pub fn idm_oauth2_rs_delete(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_delete(id))
}
pub fn idm_oauth2_rs_enable_pkce(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_enable_pkce(id))
}
pub fn idm_oauth2_rs_disable_pkce(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_disable_pkce(id))
}
pub fn idm_oauth2_rs_enable_legacy_crypto(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_enable_legacy_crypto(id))
}
pub fn idm_oauth2_rs_disable_legacy_crypto(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.idm_oauth2_rs_disable_legacy_crypto(id))
}
pub fn recycle_bin_list(&self) -> Result<Vec<Entry>, ClientError> {
tokio_block_on(self.asclient.recycle_bin_list())
}
pub fn recycle_bin_get(&self, id: &str) -> Result<Option<Entry>, ClientError> {
tokio_block_on(self.asclient.recycle_bin_get(id))
}
pub fn recycle_bin_revive(&self, id: &str) -> Result<(), ClientError> {
tokio_block_on(self.asclient.recycle_bin_revive(id))
}
}