Skip to content

Commit 3ccd6f2

Browse files
committed
Create dev mode evals override
1 parent 7e31843 commit 3ccd6f2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ VOTE_SLACK_APP_TOKEN=
2929
VOTE_SLACK_BOT_TOKEN=
3030
```
3131

32-
You can also set `DEV_DISABLE_ACTIVE_FILTERS="true"` to disable the requirements that you be active
32+
### Dev Overrides
33+
`DEV_DISABLE_ACTIVE_FILTERS="true"` will disable the requirements that you be active to vote
34+
`DEV_FORCE_IS_EVALS="true"` will force vote to treat all users as the Evals director
3335

3436
## Linting
3537
These will be checked by CI

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
VOTE_OIDC_SECRET: "${VOTE_OIDC_SECRET}"
1414
VOTE_STATE: 27a28540e47ec786b7bdad03f83171b3
1515
DEV_DISABLE_ACTIVE_FILTERS: "${DEV_DISABLE_ACTIVE_FILTERS}"
16+
DEV_FORCE_IS_EVALS: "${DEV_FORCE_IS_EVALS}"
1617
ports:
1718
- "127.0.0.1:8080:8080"
1819

main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import (
2626
var VOTE_TOKEN = os.Getenv("VOTE_TOKEN")
2727
var CONDITIONAL_GATEKEEP_URL = os.Getenv("VOTE_CONDITIONAL_URL")
2828
var VOTE_HOST = os.Getenv("VOTE_HOST")
29+
30+
// Dev mode flags
2931
var DEV_DISABLE_ACTIVE_FILTERS bool = os.Getenv("DEV_DISABLE_ACTIVE_FILTERS") == "true"
32+
var DEV_FORCE_IS_EVALS bool = os.Getenv("DEV_FORCE_IS_EVALS") == "true"
3033

3134
func inc(x int) string {
3235
return strconv.Itoa(x + 1)
@@ -123,7 +126,7 @@ func main() {
123126
c.HTML(200, "create.tmpl", gin.H{
124127
"Username": claims.UserInfo.Username,
125128
"FullName": claims.UserInfo.FullName,
126-
"IsEvals": containsString(claims.UserInfo.Groups, "eboard-evaluations"),
129+
"IsEvals": isEvals(claims.UserInfo),
127130
})
128131
}))
129132

@@ -184,7 +187,7 @@ func main() {
184187
poll.Options = []string{"Pass", "Fail", "Abstain"}
185188
}
186189
if poll.Gatekeep {
187-
if !slices.Contains(claims.UserInfo.Groups, "eboard-evaluations") {
190+
if !isEvals(claims.UserInfo) {
188191
c.HTML(403, "unauthorized.tmpl", gin.H{
189192
"Username": claims.UserInfo.Username,
190193
"FullName": claims.UserInfo.FullName,
@@ -503,6 +506,11 @@ func main() {
503506
r.Run()
504507
}
505508

509+
// isEvals determines if the current user is evals, allowing for a dev mode override
510+
func isEvals(user cshAuth.CSHUserInfo) bool {
511+
return DEV_FORCE_IS_EVALS || containsString(user.Groups, "eboard-evaluations")
512+
}
513+
506514
// canVote determines whether a user can cast a vote.
507515
//
508516
// returns an integer value: 0 is success, 1 is database error, 3 is not active, 4 is gatekept, 9 is already voted

0 commit comments

Comments
 (0)