Documentation
¶
Index ¶
Constants ¶
View Source
const ( CookieKeyJWTPayload = "jwtPayload" CookieKeyJWTSignature = "jwtSignature" CookieKeyRefreshToken = "jwtRefreshToken" CookieKeyOIDCToken = "oidcToken" CookieKeyOIDCRefreshToken = "oidcRefreshToken" )
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶
func HashAndSalt ¶
func IsValidBcryptHash ¶ added in v0.55.0
IsValidBcryptHash reports whether hash looks like a valid bcrypt hash. It does NOT verify the hash against any password — it only checks the format (prefix, cost, length).
Types ¶
type Crypto ¶
type Crypto interface {
Encrypt(spec *modelV1.SecretSpec) error
// Decrypt decrypts the spec fields in place.
// Returns true if the data was encrypted with the old format and needs re-encryption.
Decrypt(spec *modelV1.SecretSpec) (bool, error)
}
type JWT ¶
type JWT interface {
SignedAccessToken(login string, providerInfo ProviderInfo, persistedClaims map[string][]string) (string, error)
SignedRefreshToken(login string, providerInfo ProviderInfo, persistedClaims map[string][]string) (string, error)
// CreateAccessTokenCookie will create two different cookies that contain a piece of the token.
// As a reminder, a JWT token has the following structure: header.payload.signature
// The first cookie will contain the struct header.payload that can then be manipulated by Javascript
// The second cookie will contain the signature, and it won't be accessible by Javascript.
CreateAccessTokenCookie(accessToken string) (*http.Cookie, *http.Cookie)
DeleteAccessTokenCookie() (*http.Cookie, *http.Cookie)
CreateRefreshTokenCookie(refreshToken string) *http.Cookie
DeleteRefreshTokenCookie() *http.Cookie
// OIDC Token Cookie stores the token from external IDP, to help implement a grafana feature OAuthPassThrough.
// this token will be passed to datasources/globalDatasources when httpProxy.config.OauthPassthrough set to true.
CreateOIDCTokenCookie(token *oauth2.Token) *http.Cookie
DeleteOIDCTokenCookie() *http.Cookie
CreateOIDCRefreshTokenCookie(refreshToken string) *http.Cookie
DeleteOIDCRefreshTokenCookie() *http.Cookie
ValidateRefreshToken(token string) (*JWTClaims, error)
GetExpiresIn() int64
}
type JWTClaims ¶ added in v0.53.0
type JWTClaims struct {
jwt.RegisteredClaims
ProviderInfo
// PersistedClaims holds selected upstream token claim values keyed by claim name.
// Values are []string because OAuth/OIDC claims can be multi-valued (e.g. roles: ["admin","viewer"]).
// Omitted for native-auth tokens.
// +optional
PersistedClaims map[string][]string `json:"prc,omitempty"`
}
type ProviderInfo ¶ added in v0.53.0
type TokenRefresher ¶ added in v0.55.0
TokenRefresher is a function that attempts to refresh the upstream OIDC/OAuth token using the stored refresh token. It should set new cookies on success or clear them on failure. It returns the new access token, or an empty string if the token has not been refreshed. As the new cookies are only set in the response, the returned token is the only way to use it in the current request.
Click to show internal directories.
Click to hide internal directories.