remove query param

This commit is contained in:
Milo Schwartz
2024-11-27 14:36:10 -05:00
parent b151c32348
commit bf764c2b17
2 changed files with 2 additions and 6 deletions

View File

@@ -7,6 +7,5 @@ summary: Middleware auth bouncer for Pangolin
testData: testData:
apiBaseUrl: http://localhost:3001/api/v1 apiBaseUrl: http://localhost:3001/api/v1
sessionQueryParameter: __pang_sess
userSessionCookieName: session userSessionCookieName: session
resourceSessionCookieName: resource_session resourceSessionCookieName: resource_session

View File

@@ -11,7 +11,6 @@ import (
type Config struct { type Config struct {
APIBaseUrl string `json:"apiBaseUrl"` APIBaseUrl string `json:"apiBaseUrl"`
SessionQueryParameter string `json:"sessionQueryParameter"`
UserSessionCookieName string `json:"userSessionCookieName"` UserSessionCookieName string `json:"userSessionCookieName"`
ResourceSessionCookieName string `json:"resourceSessionCookieName"` ResourceSessionCookieName string `json:"resourceSessionCookieName"`
} }
@@ -41,7 +40,6 @@ type Badger struct {
next http.Handler next http.Handler
name string name string
apiBaseUrl string apiBaseUrl string
sessionQueryParameter string
userSessionCookieName string userSessionCookieName string
resourceSessionCookieName string resourceSessionCookieName string
} }
@@ -51,7 +49,6 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
next: next, next: next,
name: name, name: name,
apiBaseUrl: config.APIBaseUrl, apiBaseUrl: config.APIBaseUrl,
sessionQueryParameter: config.SessionQueryParameter,
userSessionCookieName: config.UserSessionCookieName, userSessionCookieName: config.UserSessionCookieName,
resourceSessionCookieName: config.ResourceSessionCookieName, resourceSessionCookieName: config.ResourceSessionCookieName,
}, nil }, nil
@@ -105,12 +102,12 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return return
} }
if !result.Data.Valid { // only do this if for some reason the API doesn't return a redirect and it's not valid if !result.Data.Valid {
http.Error(rw, "Unauthorized", http.StatusUnauthorized) http.Error(rw, "Unauthorized", http.StatusUnauthorized)
return return
} }
fmt.Println("serving authorized") fmt.Println("authorized")
p.next.ServeHTTP(rw, req) p.next.ServeHTTP(rw, req)
} }