Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Facchetti committed Jul 5, 2023
1 parent eb9a8d9 commit 650cb68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pkg/portal/middleware/intAAD.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ func (a IntAAD) AAD(h http.Handler) http.Handler {
Groups string
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
a.log.Errorf("running AAD middleware from int")
for _, v := range r.Cookies() {
a.log.Errorf("cookies name %s value %s", v.Name, v.Value)

Check failure on line 53 in pkg/portal/middleware/intAAD.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary trailing newline (whitespace)
}
groups := ""
username := ""

//here we use cookies because selenium doesn't allow us to set headers
for _, v := range r.Cookies() {
switch v.Name {
case IntGroupsKey:
groups = v.Value

case IntUsernameKey:
userInfo := userinfo{}
json.Unmarshal([]byte(v.Value), &userInfo)
a.log.Infof("username is %s", userInfo.Username)
a.log.Infof("groups are %s", userInfo.Groups)
a.log.Errorf("username is %s", userInfo.Username)
a.log.Errorf("groups are %s", userInfo.Groups)
if string(userInfo.Password) != string(a.sessionKey) {
a.log.Debug("password did not match")
h.ServeHTTP(w, r)
Expand All @@ -72,7 +74,7 @@ func (a IntAAD) AAD(h http.Handler) http.Handler {
case IntPasswordKey:
if v.Value != string(a.sessionKey) {
//discard all values and continue
a.log.Info("session key is different from the expected one")
a.log.Errorf("session key is different from the expected one")

groups = ""
username = ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/portal/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (p *portal) setupRouter(kconfig *kubeconfig.Kubeconfig, prom *prometheus.Pr
disableOauthOption := os.Getenv("DISABLE_OAUTH")
if disableOauthOption == "true" || env.IsLocalDevelopmentMode() || env.IsCI() {
p.log.Error("running in int")
p.aad, err = middleware.NewIntAAD(p.sessionKey, p.audit)
p.aad, err = middleware.NewIntAAD(p.sessionKey, p.log)
} else {
p.log.Error("not running in int")
p.aad, err = middleware.NewAAD(p.log, p.audit, p.env, p.baseAccessLog, p.hostname, p.sessionKey, p.clientID, p.clientKey, p.clientCerts, allGroups,
Expand Down
1 change: 1 addition & 0 deletions test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func adminPortalSessionSetup() (string, *selenium.WebDriver) {
if !ok {
log.Fatal("AZURE_PORTAL_ELEVATED_GROUPS_IDS is not set")
}
log.Infof("adding groups %s", elevatedGroups)

msiKVAuthorizer, err := _env.NewMSIAuthorizer(env.MSIContextRP, _env.Environment().KeyVaultScope)
if err != nil {
Expand Down

0 comments on commit 650cb68

Please sign in to comment.