Documentation ¶
Index ¶
- Constants
- func Authorize(c *gin.Context)
- func GoetheEntry() *gin.Engine
- func Init(c *gin.Context)
- func IssueJWT(claims *jwt.MapClaims) (string, error)
- func LoadAuthLevel(c *gin.Context)
- func RequireAuthLevel(level GOETHE_AUTH_LEVEL) gin.HandlerFunc
- func VerifyJWT(c *gin.Context, tokenString string) (*jwt.Token, error)
- type GCallbacks
- type GClaims
- type GOETHE_AUTH_LEVEL
- type ResponseData
Constants ¶
View Source
const ( ENDPOINT_NAME = "Chk" HEADER_SERVICE_NAME = "X-SERVICE-NAME" HEADER_SERVICE_KEY = "X-SERVICE-KEY" HEADER_ACCESS_KEY = "X-ACCESS-KEY" )
View Source
const TokenValidity = time.Hour * 3
Variables ¶
This section is empty.
Functions ¶
func Authorize ¶
Authorize service with key if JWT was already issued, reissues the token, assigns authLevel to context
func GoetheEntry ¶
func Init ¶
Initialize service with name and key or just with name, creates new JWT token, assigns authLevel to context
func RequireAuthLevel ¶
func RequireAuthLevel(level GOETHE_AUTH_LEVEL) gin.HandlerFunc
- Generates middleware function to require authLevel *
- Usage:
- gWithMiddleware := engine.Group("/RequiresAuthLevel", requireAuthLevel(goethe.AUTH_SERVICE_KEY))
- {
- endpoint_groups.RegisterAppGroup(appGroup)
- }
Types ¶
type GCallbacks ¶
type GCallbacks struct { BeforeIssueJWT func(c *gin.Context, claims *jwt.MapClaims) error OnVerifyCredentials func(name, key []byte) GOETHE_AUTH_LEVEL OnVerifyClaims func(c *gin.Context, claims *jwt.MapClaims) error }
var Callbacks *GCallbacks = nil
type GClaims ¶
type GClaims struct { NeedReclaim bool Claims jwt.MapClaims }
allows us to define custom actions on jwt.MapClaims
func (*GClaims) NewResponse ¶
func (G *GClaims) NewResponse(action []string, data map[string]interface{}, code int) *ResponseData
NewResponse creates a new ResponseData object
action: the action that was performed data: the data to be sent code: the HTTP status code
returns: a pointer to a ResponseData object
func (*GClaims) ReclaimJWT ¶
func (*GClaims) RemoveClaim ¶
type GOETHE_AUTH_LEVEL ¶
type GOETHE_AUTH_LEVEL uint8
const ( AUTH_NONE GOETHE_AUTH_LEVEL = iota // none authentication AUTH_SERVICE_NAME // valid service name provided AUTH_SERVICE_WRONG_KEY // service name and key, but key wrong AUTH_SERVICE_KEY // both service name and key were valid AUTH_USER_LOGGED_IN // user is logged in )
type ResponseData ¶
Click to show internal directories.
Click to hide internal directories.