Skip to content

Commit 73e1696

Browse files
committed
docs: Document new extra for oauth2 support
1 parent 1f8f779 commit 73e1696

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Add authentication and authorization to your FastAPI app via dependencies.
1010

1111
## Installation
1212

13+
With OAuth2/OIDC support:
14+
15+
```bash
16+
pip install fastapi-security[oauth2]
17+
```
18+
19+
With basic auth only:
20+
1321
```bash
1422
pip install fastapi-security
1523
```

docs/index.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,39 @@
22

33
FastAPI-Security is a package that you can use together with [FastAPI](https://fastapi.tiangolo.com/) to easily add authentication and authorization.
44

5+
## Installation
6+
7+
With OAuth2/OIDC support:
8+
9+
```bash
10+
pip install fastapi-security[oauth2]
11+
```
12+
13+
With basic auth only:
14+
15+
```bash
16+
pip install fastapi-security
17+
```
18+
519
## Key features
620

7-
- Authentication via JWT-based OAuth 2 access tokens and via Basic Auth
21+
With base install:
22+
- Authentication via HTTP Basic Auth
823
- Pydantic-based `User` model for authenticated and anonymous users
9-
- Sub-classable `UserPermission` dependency to check against the `permissions` attribute returned in OAuth 2 access tokens
24+
- Limit endpoint access to authenticated users
25+
- Limit endpoint access to users with an explicit set of user permissions
26+
- Easily create endpoint for users to check their user info and permissions
27+
28+
With extra `oauth2`:
29+
- Authentication via JWT-based OAuth 2 access tokens in addition to HTTP Basic Auth
1030
- Ability to extract user info from access tokens via OpenID Connect
31+
- Permissions are checked agains the `permissions` attribute returned in OAuth 2 access tokens
1132

1233
## Current limitations
1334

1435
- Only supports validating access tokens using public keys from a JSON Web Key Set (JWKS) endpoint. I.e. for use with external identity providers such as Auth0 and ORY Hydra.
1536
- Permissions can only be picked up automatically from OAuth2 tokens, from the non-standard `permissions` list attribute (Auth0 provides this, maybe other identity providers as well). For all other use cases, `permission_overrides` must be used. For example if there's a basic auth user called `user1` you can set `permission_overrides={"user1": ["*"]}` to give the user access to all permissions, or `permission_overrides={"user1": ["products:create"]}` to only assign `user1` with the permission `products:create`.
1637

17-
Installation
18-
19-
```
20-
pip install fastapi-security
21-
```
22-
2338
## Usage example
2439

2540
An example app using FastAPI-Security [can be found here](https://github.com/jacobsvante/fastapi-security/tree/main/examples).

0 commit comments

Comments
 (0)