mirror of
https://github.com/fosrl/badger.git
synced 2026-02-08 05:56:46 +00:00
remove query param
This commit is contained in:
@@ -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
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user