Documentation ¶
Index ¶
- Variables
- func DecodeToken(token string, signingKey string) (*jwt.Token, *jwt.MapClaims, error)
- func GenerateToken(claims map[string]interface{}, expireIn *time.Duration, signingKey string) (*string, error)
- func GetValidSession(sessions *[]models.AuthSession, signingKey string) (*models.AuthSession, []string)
- func ParseAccessToken(r *http.Request, w *http.ResponseWriter) (*persistent.User, *jwt.MapClaims)
- func SecureCompare(given string, actual string) bool
- func SetCors(w *http.ResponseWriter)
- type OceanBrigdeClaims
Constants ¶
This section is empty.
Variables ¶
View Source
var ClaimKeys = OceanBrigdeClaims{
Email: "oceanbridge_email",
Scopes: "oceanbridge_scopes",
}
ClaimKeys defines the claim key constants
View Source
var DevMode bool = strings.ToLower(os.Getenv("CARGOWISE_OCEANBRIDGE_REST_WRAPPER_DEV_MODE")) == "true"
DevMode defines if the application is run on dev mode
Functions ¶
func DecodeToken ¶
DecodeToken to get the claims/values of a JWT
func GenerateToken ¶
func GenerateToken(claims map[string]interface{}, expireIn *time.Duration, signingKey string) (*string, error)
GenerateToken a JWT token
func GetValidSession ¶
func GetValidSession(sessions *[]models.AuthSession, signingKey string) (*models.AuthSession, []string)
GetValidSession gets a valid session from the list, also returns the list of invalid sessions for clean up purpose
func ParseAccessToken ¶
func ParseAccessToken(r *http.Request, w *http.ResponseWriter) (*persistent.User, *jwt.MapClaims)
ParseAccessToken will try to parse the JWT, from the Authorization header then return the user instance as well as the decoded claims map
func SecureCompare ¶
SecureCompare performs a constant time compare of two strings to limit timing attacks. https://github.com/go-macaron/auth/blob/884c0e6c9b92ceebf12101d6cf1417fe0f61bcac/util.go
Types ¶
type OceanBrigdeClaims ¶
OceanBrigdeClaims struct
Click to show internal directories.
Click to hide internal directories.