This has client and server examples for:
- Client - Fetching an access token JWT, and sending it in request to "Server"
- Server - Validating a JWT sent from a client
Note: This is likely mostly a Keycloak specific implementation but I'm not entirely sure.
As you explore the code, start with these classes in mostly this order:
- JwtAuth.FunctionDemo.ClientServer
- JwtAuth.FunctionDemo.Startup
- JwtAuth.Core.DefaultJwtFetcher
- JwtAuth.Http.NetHttpAuthorizer
- JwtAuth.Core.DefaultJwtValidator
Prerequisites:
- Azure Function runtime
- Visual Studio, Jetbrains Rider, or Azure Function CLI
- Copy
JwtAuth.FunctionDemo/local.settings.dist.json
toJwtAuth.FunctionDemo/local.settings.json
- Fill-out your identity server values in
JwtAuth.FunctionDemo/local.settings.json
- Start the
JwtAuth.FunctionDemo
project. - Send a request with Postman or
curl
like:
curl http://localhost:7071/api/Client
- You should see a JSON response body like this:
{
"accessToken": "<JWT access token>",
"serverResponseBody": {
"result": "Accepted"
}
}