mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
31 lines
779 B
Go
31 lines
779 B
Go
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License.AGPL.txt in the project root for license information.
|
|
|
|
package oidc
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
)
|
|
|
|
type StateClaims struct {
|
|
// Internal client ID
|
|
ClientConfigID string `json:"clientId"`
|
|
ReturnToURL string `json:"returnTo"`
|
|
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
func NewStateJWT(clientConfigID string, returnURL string, issuedAt, expiry time.Time) *jwt.Token {
|
|
return jwt.NewWithClaims(jwt.SigningMethodHS256, &StateClaims{
|
|
ClientConfigID: clientConfigID,
|
|
ReturnToURL: returnURL,
|
|
RegisteredClaims: jwt.RegisteredClaims{
|
|
ExpiresAt: jwt.NewNumericDate(expiry),
|
|
IssuedAt: jwt.NewNumericDate(issuedAt),
|
|
},
|
|
})
|
|
}
|