Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard: allow multiple allowed authentication domains #5370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion dashboard/app/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func checkAccessLevel(c context.Context, r *http.Request, level AccessLevel) err
// AuthDomain is broken in AppEngine tests.
var isBrokenAuthDomainInTest = false

func emailInAuthDomains(email string, authDomains ...string) bool {
for _, authDomain := range authDomains {
if authDomain != "" && strings.HasSuffix(email, authDomain) {
return true
}
}

return false
}

func accessLevel(c context.Context, r *http.Request) AccessLevel {
if user.IsAdmin(c) {
switch r.FormValue("access") {
Expand All @@ -60,10 +70,12 @@ func accessLevel(c context.Context, r *http.Request) AccessLevel {
return AccessAdmin
}
u := user.Current(c)
cfg := getConfig(c)
authDomains := append(cfg.AuthDomains, cfg.AuthDomain)
if u == nil ||
// Devappserver does not pass AuthDomain.
u.AuthDomain != "gmail.com" && !isBrokenAuthDomainInTest ||
!strings.HasSuffix(u.Email, getConfig(c).AuthDomain) {
!emailInAuthDomains(u.Email, authDomains...) {
return AccessPublic
}
return AccessUser
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
// Config used in tests.
var testConfig = &GlobalConfig{
AccessLevel: AccessPublic,
AuthDomain: "@syzkaller.com",
AuthDomains: []string{"@syzkaller.com"},
Clients: map[string]string{
"reporting": "reportingkeyreportingkeyreportingkey",
},
Expand Down
4 changes: 3 additions & 1 deletion dashboard/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
type GlobalConfig struct {
// Min access levels specified hierarchically throughout the config.
AccessLevel AccessLevel
// Email suffix of authorized users (e.g. "@foobar.com").
// Deprecated - Email suffix of authorized users (e.g. "@foobar.com").
AuthDomain string
// Email suffixes of authorized users (e.g. []string{"@foo.com","@bar.org"}).
AuthDomains []string
// Google Analytics Tracking ID.
AnalyticsTrackingID string
// URL prefix of source coverage reports.
Expand Down
2 changes: 1 addition & 1 deletion docs/setup_syzbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func init() {
}
var prodConfig = &GlobalConfig{
AccessLevel: AccessPublic,
AuthDomain: "@google.com",
AuthDomains: []string{"@google.com"},
CoverPath: "https://storage.googleapis.com/syzkaller/cover/",
Clients: map[string]string{
"$CI_HOSTNAME": "$CI_KEY",
Expand Down
Loading