Documentation
¶
Index ¶
- Constants
- func GenerateJwksJSON(publicKey *ecdsa.PublicKey) ([]byte, error)
- func GenerateKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
- func GenerateToken(username string, privateKey *ecdsa.PrivateKey, id int, issuer string, ...) (string, error)
- func GetAccessToken(username string, privateKey *ecdsa.PrivateKey, id int) (string, error)
- func GetRefreshToken(username string, private *ecdsa.PrivateKey, id int) (string, error)
- func JWKSHandler(jwksJSON []byte) http.Handler
- func PublicKeyFromJwksJSON(jwksJSON []byte) (*ecdsa.PublicKey, error)
- func TokenFromAuthorization(authorization string) string
- type Claims
- type JWK
- type JWKS
Constants ¶
View Source
const AccessIssuer = "casaos"
AccessIssuer is the issuer of an access token, the only token Validate accepts.
View Source
const JWKSPath = ".well-known/jwks.json"
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
func GenerateToken ¶
func GetAccessToken ¶
get AccessToken
func GetRefreshToken ¶
func JWKSHandler ¶
func TokenFromAuthorization ¶ added in v0.4.31
TokenFromAuthorization is the user token in an Authorization header value: the bare token (as CasaOS clients have always sent it), or the standard `Bearer <token>` (RFC 6750; the scheme is case-insensitive, RFC 7235). Every other scheme, `Internal <secret>` among them, is returned as it came: it is rejected as an invalid token. Only a space separates the scheme (RFC 7235 SP): `Bearer<TAB>token` is returned whole, and rejected too.
Types ¶
type Claims ¶
type Claims struct {
Username string `json:"username"`
ID int `json:"id"`
jwt.RegisteredClaims
}
func ParseToken ¶
Click to show internal directories.
Click to hide internal directories.