1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-05-29 23:17:38 +02:00

Fix json input

Everything has to go through a json round trip to work.
HTTP Request has function members within it that means it cannot go 
through a JSON round trip, so nil that for now
This commit is contained in:
Joel Speed 2021-04-03 12:14:03 +01:00
parent 56a98c3fa9
commit 5ee52143e8
No known key found for this signature in database
GPG Key ID: 6E80578D6751DEFB

View File

@ -7,9 +7,9 @@ import (
"github.com/open-policy-agent/opa/rego"
)
type authInput struct {
request *http.Request
session *sessionsapi.SessionState
type AuthInput struct {
Request *http.Request
Session *sessionsapi.SessionState
}
func authorize(req *http.Request, session *sessionsapi.SessionState) (bool, error) {
@ -21,7 +21,7 @@ package oauth2proxy
default allow = false
allow {
endswith(input.session.email, "@bar.com")
endswith(input.Session.Email, "@bar.com")
}
`),
)
@ -31,9 +31,9 @@ allow {
return false, err
}
input := rego.EvalInput(authInput{
request: req,
session: session,
input := rego.EvalInput(AuthInput{
Request: nil,
Session: session,
})
result, err := query.Eval(req.Context(), input)