Alex Tugarev 76c61533a6
[OIDC] Enable mark client config as "active" (#17365)
* [gitpod-db] Add `d_b_oidc_client_config.active` field

* [papi] Add OIDCClientConfig.active to proto def

* [gitpod-db] Add OIDCClientConfig.active

* [papi] Add `activate` param to `/oidc/start` endpoint handler

If provided it should mark the OIDC client config as `active` in the DB.

* Fix propagation of state params and add tests.

* fix import of deprecated ioutil

* refactor GetStartParams

* consider `activate` from create request
2023-04-27 21:35:36 +08:00

27 lines
668 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 {
StateParams StateParams `json:"stateParams"`
jwt.RegisteredClaims
}
func NewStateJWT(stateParams StateParams, issuedAt, expiry time.Time) *jwt.Token {
return jwt.NewWithClaims(jwt.SigningMethodHS256, &StateClaims{
StateParams: stateParams,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(expiry),
IssuedAt: jwt.NewNumericDate(issuedAt),
},
})
}