1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-05-31 23:19:50 +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" "github.com/open-policy-agent/opa/rego"
) )
type authInput struct { type AuthInput struct {
request *http.Request Request *http.Request
session *sessionsapi.SessionState Session *sessionsapi.SessionState
} }
func authorize(req *http.Request, session *sessionsapi.SessionState) (bool, error) { func authorize(req *http.Request, session *sessionsapi.SessionState) (bool, error) {
@ -21,7 +21,7 @@ package oauth2proxy
default allow = false default allow = false
allow { allow {
endswith(input.session.email, "@bar.com") endswith(input.Session.Email, "@bar.com")
} }
`), `),
) )
@ -31,9 +31,9 @@ allow {
return false, err return false, err
} }
input := rego.EvalInput(authInput{ input := rego.EvalInput(AuthInput{
request: req, Request: nil,
session: session, Session: session,
}) })
result, err := query.Eval(req.Context(), input) result, err := query.Eval(req.Context(), input)