# README
jwt-auth
Authenticate requests with jwt, extensible claims and a specific jwks-set.
This library provides a way to decode a jwt-token with self-defined claims. Additionally one can specify a function to retrieve the JWKS. See here for further information about JWKS.
Installation
- with go-get:
go get github.com/fr3dch3n/jwt-auth
- with dep:
dep ensure --add github.com/fr3dch3n/jwt-auth
Usage example
Initialization
First the JWKS has to be initialized via one of the following ways:
Initialize jwk-set from json in AWS-SSM
jwt.NewAuth("/path/in/ssm", auth.FetchJwksConfigurationFromSSM)
Initialize jwk-set from local json-file
jwt.NewAuth("file/to/local/jwks.json", auth.FetchJwksConfigurationFromFS)
Authorizing requests
Then the jwt-component can be used to authenticate requests. To use specific claims, just extend the jwtgo.StandardClaims.
package handler
import (
"fmt"
jwtgo "github.com/dgrijalva/jwt-go"
"github.com/fr3dch3n/jwt-auth"
"net/http"
)
func MyAuthenticatedHandler(w http.ResponseWriter, r *http.Request) {
authHeader := r.Header.Get("Authorization")
token, err := jwt.DecodeToken(authHeader, &jwtgo.StandardClaims{})
if err != nil {
fmt.Println(err)
}
fmt.Println(token)
}
Release History
- 0.0.1
- initial release
Meta
Distributed under the Apache 2.0 license. See LICENSE
for more information.
Contributing
- Fork it (https://github.com/fr3dch3n/jwt-auth/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author