Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/public-api-server/pkg/oidc/state_jwt.go
2500 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package oidc
6
7
import (
8
"time"
9
10
"github.com/golang-jwt/jwt/v5"
11
)
12
13
type StateClaims struct {
14
StateParams StateParams `json:"stateParams"`
15
jwt.RegisteredClaims
16
}
17
18
func NewStateJWT(stateParams StateParams, issuedAt, expiry time.Time) *jwt.Token {
19
return jwt.NewWithClaims(jwt.SigningMethodHS256, &StateClaims{
20
StateParams: stateParams,
21
RegisteredClaims: jwt.RegisteredClaims{
22
ExpiresAt: jwt.NewNumericDate(expiry),
23
IssuedAt: jwt.NewNumericDate(issuedAt),
24
},
25
})
26
}
27
28