Documentation ¶
Index ¶
- Constants
- func AudienceInToken(t *jwt.Token, aud string) bool
- func GenTokenResponse(s string) response.Response
- func Generate(privateKey []byte, tr TokenRequest, iss string) (string, error)
- func ParseAudJson(b []byte) ([]string, error)
- func ScopeInToken(t *jwt.Token, scope string) bool
- func StringToToken(publicKey []byte, t string) (*jwt.Token, error)
- func Verify(publicKey []byte, req *http.Request) (*jwt.Token, error)
- type DecodedToken
- type KeyPolicy
- type Policy
- type TokenRequest
- type TokenResponse
- type TokenScope
Constants ¶
View Source
const ( KeyPolicyDeny = "deny" KeyPolicyRead = "read" KeyPolicyWrite = "write" KeyPolicyCreate = "create" KeyPolicyDelete = "delete" ScopedPolicyType = "scope" EndpointPolicyType = "policy" )
Variables ¶
This section is empty.
Functions ¶
func AudienceInToken ¶
Returns a boolean value whether or not the given audience string exists in the token claim 'aud'.
if there is no 'aud' claim, this will always return false
func GenTokenResponse ¶
returns a response.Response object from a given JWT token
func ParseAudJson ¶
func ScopeInToken ¶
searches the 'role:' claims for the given role and returns the value (if any) and a boolean indicating success
func StringToToken ¶
Types ¶
type DecodedToken ¶
type DecodedToken struct { UserId string `json:"user_id"` Audience []string `json:"aud"` Scope []string `json:"scope"` Data map[string]string `json:"data"` }
func Decode ¶
func Decode(t *jwt.Token) DecodedToken
type TokenRequest ¶
type TokenRequest struct { ClientId string `json:"client_id"` Audience []string `json:"aud"` UserId string `json:"user_id"` Timestamp int64 `json:"timestamp"` Scope []string `json:"scope"` Data map[string]string `json:"data"` }
func GenTokenRequest ¶
func GenTokenRequest(clientid, userid string, audience []string, scope []string, data map[string]string) TokenRequest
compiles the data for a token into a TokenRequest
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
type TokenScope ¶
type TokenScope struct {
Name string `json:"name"`
}
Click to show internal directories.
Click to hide internal directories.