You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add authentication and authorization to your application.
4
10
5
11
This library is meant to be used with a [PropelAuth](https://www.propelauth.com/) account.
6
12
You can sign up and get started for free.
7
13
8
-
# Initialize
14
+
##Initialize
9
15
10
16
First, you'll need to initialize the library. You can either call `PropelAuth::init`
11
17
or `PropelAuth::fetch_and_init` (which will fetch any unspecified metadata).
@@ -17,7 +23,7 @@ let auth = PropelAuth::fetch_and_init(AuthOptions {
17
23
}).await.expect("Unable to initialize authentication");
18
24
```
19
25
20
-
# Usage / Protecting APIs
26
+
##Usage / Protecting APIs
21
27
22
28
-[Axum](#axum)
23
29
-[Actix](#actix)
@@ -40,7 +46,7 @@ let app = Router::new()
40
46
.layer(auth_layer); // <-- here
41
47
```
42
48
43
-
You can then take `User` in as an argument, which will look for an [access token](https://docs.propelauth.com/overview/access-token/) in the Authorization header.
49
+
You can then take `User` in as an argument, which will look for an [access token](https://docs.propelauth.com/guides-and-examples/guides/access-tokens) in the Authorization header.
44
50
45
51
```rust
46
52
// User will automatically return a 401 (Unauthorized) if a valid access token wasn't provided
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/rbac/) they have.
58
+
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/authorization/rbac) they have.
53
59
54
60
```rust
55
61
// If the user isn't in the provided organization, a 403 is returned
@@ -90,7 +96,7 @@ HttpServer::new(move || {
90
96
})
91
97
```
92
98
93
-
You can then take `User` in as an argument, which will look for an [access token](https://docs.propelauth.com/overview/access-token/) in the Authorization header.
99
+
You can then take `User` in as an argument, which will look for an [access token](https://docs.propelauth.com/guides-and-examples/guides/access-tokens) in the Authorization header.
94
100
95
101
```rust
96
102
// User will automatically return a 401 (Unauthorized) if a valid access token wasn't provided
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/rbac/) they have.
109
+
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/authorization/rbac) they have.
104
110
105
111
```rust
106
112
// If the user isn't in the provided organization, a 403 is returned
@@ -136,7 +142,7 @@ propelauth = { version >= "0.12.1", features = ["rustls"], default-features = fa
136
142
137
143
## Other
138
144
139
-
After initializing `auth`, you can verify [access tokens](https://docs.propelauth.com/overview/access-token/) by passing in the Authorization header (formatted `Bearer TOKEN`):
145
+
After initializing `auth`, you can verify [access tokens](https://docs.propelauth.com/guides-and-examples/guides/access-tokens) by passing in the Authorization header (formatted `Bearer TOKEN`):
Err(_) => { /* invalid access token, typically we return a 401 Unauthorized here */ }
146
152
}
147
153
```
148
-
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/rbac/) they have.
154
+
You can also check which [organizations](https://docs.propelauth.com/overview/organizations/) the user is in, and which [roles and permissions](https://docs.propelauth.com/overview/authorization/rbac) they have.
149
155
150
156
```rust
151
157
letorg=auth.validate_org_membership(
@@ -163,7 +169,7 @@ let org = user.validate_org_membership(
163
169
164
170
And finally, you can make API calls directly from `auth.user()` and `auth.org()`
165
171
166
-
# Where do the access tokens come from?
172
+
##Where do the access tokens come from?
167
173
168
174
They come from your frontend.
169
-
You can read more about integrating your frontend [here](https://docs.propelauth.com/getting-started/frontend-integration/).
175
+
You can read more about integrating your frontend [here](https://docs.propelauth.com/getting-started/quickstart-fe).
0 commit comments