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
/*!
Huskarl provides tools for implementing secure `OAuth2` clients in rust.
This library provides a number of grant implementations, each of which is configured
with a set of parameters that define how the grant/workflow should progress.
The library also provides a caching layer for token responses; and a HTTP authorizer
that can be used to make authenticated requests to resource servers.
## Examples
### Client Credentials Grant
```rust
# use huskarl::prelude::*;
# use huskarl::core::http::HttpClient;
# use huskarl::core::secrets::{EnvVarSecret, encodings::StringEncoding};
# use huskarl::core::server_metadata::AuthorizationServerMetadata;
# use huskarl::grant::client_credentials::{ClientCredentialsGrant, ClientCredentialsGrantParameters};
# use huskarl::core::client_auth::ClientSecret;
# use huskarl::core::dpop::NoDPoP;
#
# async fn example(http_client: impl HttpClient) {
# let issuer = "https://issuer";
# let client_id = "client_id";
# let client_secret = EnvVarSecret::new("CLIENT_SECRET", &StringEncoding).unwrap();
#
let metadata = AuthorizationServerMetadata::builder()
.http_client(&http_client)
.issuer(issuer)
.build()
.await
.unwrap();
let grant = ClientCredentialsGrant::builder_from_metadata(&metadata)
.client_id(client_id)
.client_auth(ClientSecret::new(client_secret))
.dpop(NoDPoP)
.build();
let token_response = grant
.exchange(
&http_client,
ClientCredentialsGrantParameters::builder()
.scopes(vec!["test"])
.build(),
)
.await
.unwrap();
println!(
"Access token: {}",
token_response.access_token().token().expose_secret()
);
# }
```
*/
use Arc;
pub use huskarl_core as core;
/// A type-erased wrapper around a [`core::crypto::verifier::JwsVerifierPlatform`] for use as a feature-gated default.
;
/// The default JWS verifier platform for native platforms.
/// The default JWS verifier platform for WebAssembly/WebCrypto platforms.