Documentation
¶
Index ¶
- func CreateToken(user user.User, expiresIn, svcAccountID string) (string, error)
- func GetServiceAccountID(r *http.Request) string
- func GetUserID(r *http.Request) string
- func MiddlewareAuthenticationVerification(next http.Handler) http.Handler
- func SetAccessControl(api *policyAPI.API)
- func SubjectFromRequest(r *http.Request) (policyAPI.Subject, error)
- type McApiContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶
CreateToken creates a token for a user
func GetServiceAccountID ¶ added in v2.2.0
GetServiceAccountID returns the service account token id from the request (if login used a service account)
func MiddlewareAuthenticationVerification ¶
MiddlewareAuthenticationVerification verifies user auth details
func SetAccessControl ¶ added in v2.2.0
SetAccessControl wires the policy API used by auth middleware (user disabled, RBAC). Call once during server HTTP setup.
func SubjectFromRequest ¶ added in v2.2.0
SubjectFromRequest builds the access control subject from the verified request context. Fails when the request did not pass authentication - the mc_userid header is only trusted after IsValidToken has rewritten it.
Types ¶
type McApiContext ¶ added in v2.1.1
type McApiContext struct {
Tenant string `json:"tenant" yaml:"tenant"`
UserID string `json:"userId" yaml:"userId"`
ServiceAccountID string `json:"serviceAccountId" yaml:"serviceAccountId"`
}
struct used in api request
func GetAPIContext ¶ added in v2.2.0
func GetAPIContext(r *http.Request) *McApiContext
GetAPIContext returns McApiContext from request context if present
func IsValidToken ¶
func IsValidToken(r *http.Request) (*McApiContext, error)
steps to verify the authentication 1. Verify the token in header 2. Verify the token in cookie