-
Notifications
You must be signed in to change notification settings - Fork 16
/
cedar.go
71 lines (61 loc) · 1.81 KB
/
cedar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Package cedar holds a a number of application level constants and shared
resources for the Cedar application.
*/
package cedar
import (
"time"
"github.com/evergreen-ci/gimlet"
)
const (
ShortDateFormat = "2006-01-02T15:04"
)
// BuildRevision stores the commit in the git repository at build time and is
// specified with -ldflags at build time.
var BuildRevision = ""
const (
// Auth constants.
AuthTokenCookie = "cedar-token"
APIUserHeader = "Api-User"
APIKeyHeader = "Api-Key"
EvergreenAPIUserHeader = "Evergreen-Api-User"
EvergreenAPIKeyHeader = "Evergreen-Api-Key"
TokenExpireAfter = time.Hour
// Version requester types.
PatchVersionRequester = "patch_request"
GithubPRRequester = "github_pull_request"
GitTagRequester = "git_tag_request"
RepotrackerVersionRequester = "gitter_request"
TriggerRequester = "trigger_request"
MergeTestRequester = "merge_test"
AdHocRequester = "ad_hoc"
// Stats cache names.
StatsCacheBuildlogger = "buildlogger"
StatsCacheTestResults = "test_results"
StatsCachePerf = "perf"
)
var (
// Convenience slice for patch requester types.
PatchRequesters = []string{
PatchVersionRequester,
GithubPRRequester,
MergeTestRequester,
}
// Convenience slice for slice cache names.
StatsCacheNames = []string{
StatsCacheBuildlogger,
StatsCacheTestResults,
StatsCachePerf,
}
)
// GetUserMiddlewareConfiguration returns the gimlet user middleware config
// with cedar's global auth constants.
func GetUserMiddlewareConfiguration() gimlet.UserMiddlewareConfiguration {
return gimlet.UserMiddlewareConfiguration{
HeaderKeyName: APIKeyHeader,
HeaderUserName: APIUserHeader,
CookieName: AuthTokenCookie,
CookiePath: "/",
CookieTTL: TokenExpireAfter,
}
}