njwt

module
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2023 License: Apache-2.0

README

NJWT

JWT library for the Napptive projects

The purpose of this project is to provide a simple JWT library to handle the authentication tokens of the Napptive platform.

Usage

To create new tokens:

     pc := NewAuthxClaim("userID", "username")
     claim := NewClaim("tt", time.Hour, pc)

     secret := "secret"
     token, err := tokenMgr.Generate(claim, secret)

     recoveredClaim, err := tokenMgr.Recover(*token, secret, &AuthxClaim{})
     recoveredPC, ok := recClaim.PersonalClaim.(*AuthxClaim)
JWT Interceptor

To create an interceptor that validates incoming gRPC calls with a JWT on an authorization header in the context:

cfg := config.JWTConfig{
   Secret: "mysecret",
   Header: "authorization",
}

var s *grpc.Server
...
s = grpc.NewServer(interceptor.WithServerJWTInterceptor(config))

Badges

Check changes in the Main branch

License

Copyright 2023 Napptive

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis
pkg
interceptors
Package interceptors defines a set of JWT interceptors that are capable of extracting information from the request JWT, check its validity and pass the information to downstream methods in the context.
Package interceptors defines a set of JWT interceptors that are capable of extracting information from the request JWT, check its validity and pass the information to downstream methods in the context.
njwt
Package njwt provides access to a set of structures and methods related to the creation, validation, and inspection of JWT.
Package njwt provides access to a set of structures and methods related to the creation, validation, and inspection of JWT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL