Skip to content

Commit e5a31b8

Browse files
committed
Add README for oauth2 core and helidon JwtAuthFilter
1 parent 679e235 commit e5a31b8

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

avaje-oauth2-core/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# avaje-oauth2-core
2+
3+
Provides core OAuth2 features.
4+
5+
6+
### JwtVerifier
7+
8+
JwtVerifier verifies a Signed JWT Access token is valid.
9+
10+
```java
11+
String issuer = "https://cognito-idp.REGION.amazonaws.com/REGION_FOO";
12+
13+
JwtVerifier jwtVerifier = JwtVerifier.builder()
14+
.issuer(issuer)
15+
.build();
16+
17+
String rawAccessToken = ...;
18+
19+
try {
20+
// verify that the raw access token is valid, and return
21+
// the parsed AccessToken
22+
AccessToken accessToken = verifier.verifyAccessToken(rawAccessToken);
23+
} catch (JwtVerifyException exception) {
24+
// invalid access token
25+
}
26+
```
27+
28+
29+
### SignedJwt
30+
31+
Parse a SignedJwt.
32+
33+
```java
34+
String rawToken = "eyJraWQiOiJqR3lQcEc4MDNTc1ZmSjRtZERkVktE...";
35+
SignedJwt token = SignedJwt.parse(rawToken);
36+
37+
```
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# avaje-oauth2-helidon-jwtfilter
3+
4+
Provides a Helidon Filter that ensures a valid Signed JWT access token
5+
is supplied as a `Authorization` `Bearer` http header.
6+
7+
### Typical use
8+
9+
- Build a JwtVerifier typically using an issuer endpoint
10+
- Build a JwtAuthFilter
11+
- Register the JwtAuthFilter as a Filter with the Helidon Webserver
12+
13+
```java
14+
String issuer = "https://cognito-idp.REGION.amazonaws.com/REGION_FOO";
15+
16+
JwtVerifier jwtVerifier = JwtVerifier.builder()
17+
.issuer(issuer)
18+
.build();
19+
20+
JwtAuthFilter filter = JwtAuthFilter.builder()
21+
.permit("/health")
22+
.permit("/ping")
23+
.verifier(jwtVerifier)
24+
.build();
25+
```
26+
27+
## Dependency
28+
29+
```xml
30+
<dependency>
31+
<groupId>io.avaje</groupId>
32+
<artifactId>avaje-oauth2-helidon-jwtfilter</artifactId>
33+
<version>0.1</version>
34+
</dependency>
35+
```

0 commit comments

Comments
 (0)