Huiwen 9719e619be
[IdP] add user_id claim and allow to customize OIDC subject via FF (#19455)
* [papi] add user_id field to idp token

* [idp] allow to customize claim keys

* fixup update FF

* Update splitor and add more unit tests
2024-02-22 19:03:03 +02:00

44 lines
1.7 KiB
Go

// Copyright (c) 2022 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 experiments
import (
"context"
"strings"
)
const (
PersonalAccessTokensEnabledFlag = "personalAccessTokensEnabled"
OIDCServiceEnabledFlag = "oidcServiceEnabled"
SupervisorPersistServerAPIChannelWhenStartFlag = "supervisor_persist_serverapi_channel_when_start"
SupervisorUsePublicAPIFlag = "supervisor_experimental_publicapi"
ServiceWaiterSkipComponentsFlag = "service_waiter_skip_components"
IdPClaimKeysFlag = "idp_claim_keys"
)
func IsPersonalAccessTokensEnabled(ctx context.Context, client Client, attributes Attributes) bool {
return client.GetBoolValue(ctx, PersonalAccessTokensEnabledFlag, false, attributes)
}
func GetIdPClaimKeys(ctx context.Context, client Client, attributes Attributes) []string {
value := client.GetStringValue(ctx, IdPClaimKeysFlag, "undefined", attributes)
if value == "" || value == "undefined" {
return []string{}
}
return strings.Split(value, ",")
}
func IsOIDCServiceEnabled(ctx context.Context, client Client, attributes Attributes) bool {
return client.GetBoolValue(ctx, OIDCServiceEnabledFlag, false, attributes)
}
func SupervisorPersistServerAPIChannelWhenStart(ctx context.Context, client Client, attributes Attributes) bool {
return client.GetBoolValue(ctx, SupervisorPersistServerAPIChannelWhenStartFlag, true, attributes)
}
func SupervisorUsePublicAPI(ctx context.Context, client Client, attributes Attributes) bool {
return client.GetBoolValue(ctx, SupervisorUsePublicAPIFlag, false, attributes)
}