mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
26 lines
556 B
Go
26 lines
556 B
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 auth
|
|
|
|
import "context"
|
|
|
|
type contextKey int
|
|
|
|
const (
|
|
authContextKey contextKey = iota
|
|
)
|
|
|
|
func TokenToContext(ctx context.Context, token string) context.Context {
|
|
return context.WithValue(ctx, authContextKey, token)
|
|
}
|
|
|
|
func TokenFromContext(ctx context.Context) string {
|
|
if val, ok := ctx.Value(authContextKey).(string); ok {
|
|
return val
|
|
}
|
|
|
|
return ""
|
|
}
|