MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / createToken

Method createToken

server-source-code/internal/handler/auth.go:768–780  ·  view source on GitHub ↗
(userID, role string, expSec int64, sessionID string)

Source from the content-addressed store, hash-verified

766}
767
768func (h *AuthHandler) createToken(userID, role string, expSec int64, sessionID string) (string, error) {
769 claims := jwt.MapClaims{
770 "sub": userID,
771 "role": role,
772 "exp": time.Now().Add(time.Duration(expSec) * time.Second).Unix(),
773 "iat": time.Now().Unix(),
774 }
775 if sessionID != "" {
776 claims["sessionId"] = sessionID
777 }
778 token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
779 return token.SignedString([]byte(h.cfg.JWTSecret))
780}
781
782// Profile handles GET /auth/profile.
783func (h *AuthHandler) Profile(w http.ResponseWriter, r *http.Request) {

Callers 5

completeLoginMethod · 0.95
CompleteOidcLoginMethod · 0.95
CompleteDiscordLoginMethod · 0.95
SetupAdminMethod · 0.95
SignupMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected