Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/auth/config.go
2501 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 auth
6
7
import (
8
"fmt"
9
"time"
10
11
"github.com/gitpod-io/gitpod/installer/pkg/common"
12
server_lib "github.com/gitpod-io/gitpod/server/go/pkg/lib"
13
corev1 "k8s.io/api/core/v1"
14
)
15
16
type Config struct {
17
PKI PKIConfig `json:"pki"`
18
19
// Configration parameters for user sessions
20
Session SessionConfig `json:"session"`
21
}
22
23
type SessionConfig struct {
24
// How long shoud the session be valid for?
25
LifetimeSeconds int64 `json:"lifetimeSeconds"`
26
Issuer string `json:"issuer"`
27
Cookie CookieConfig `json:"cookie"`
28
}
29
30
type CookieConfig struct {
31
Name string `json:"name"`
32
MaxAge int64 `json:"maxAge"`
33
SameSite string `json:"sameSite"`
34
Secure bool `json:"secure"`
35
HTTPOnly bool `json:"httpOnly"`
36
}
37
38
func GetConfig(ctx *common.RenderContext) ([]corev1.Volume, []corev1.VolumeMount, Config) {
39
volumes, mounts, pki := getPKI()
40
lifetime := int64((7 * 24 * time.Hour).Seconds())
41
return volumes, mounts, Config{
42
PKI: pki,
43
Session: SessionConfig{
44
LifetimeSeconds: lifetime,
45
Issuer: fmt.Sprintf("https://%s", ctx.Config.Domain),
46
Cookie: CookieConfig{
47
// Caution: changing these have security implications for the application. Make sure you understand what you're doing.
48
Name: server_lib.CookieNameFromDomain(ctx.Config.Domain),
49
MaxAge: lifetime,
50
SameSite: "lax",
51
Secure: true,
52
HTTPOnly: true,
53
},
54
},
55
}
56
}
57
58