providers/proxy: fix nil error in claims
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ec04443493
commit
654e0d6245
|
@ -10,7 +10,7 @@ type Claims struct {
|
||||||
Exp int `json:"exp"`
|
Exp int `json:"exp"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Verified bool `json:"email_verified"`
|
Verified bool `json:"email_verified"`
|
||||||
Proxy ProxyClaims `json:"ak_proxy"`
|
Proxy *ProxyClaims `json:"ak_proxy"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
PreferredUsername string `json:"preferred_username"`
|
PreferredUsername string `json:"preferred_username"`
|
||||||
Groups []string `json:"groups"`
|
Groups []string `json:"groups"`
|
||||||
|
|
|
@ -70,7 +70,7 @@ func TestForwardHandleNginx_Single_Claims(t *testing.T) {
|
||||||
s, _ := a.sessions.Get(req, constants.SeesionName)
|
s, _ := a.sessions.Get(req, constants.SeesionName)
|
||||||
s.Values[constants.SessionClaims] = Claims{
|
s.Values[constants.SessionClaims] = Claims{
|
||||||
Sub: "foo",
|
Sub: "foo",
|
||||||
Proxy: ProxyClaims{
|
Proxy: &ProxyClaims{
|
||||||
UserAttributes: map[string]interface{}{
|
UserAttributes: map[string]interface{}{
|
||||||
"username": "foo",
|
"username": "foo",
|
||||||
"password": "bar",
|
"password": "bar",
|
||||||
|
|
|
@ -64,7 +64,7 @@ func TestForwardHandleTraefik_Single_Claims(t *testing.T) {
|
||||||
s, _ := a.sessions.Get(req, constants.SeesionName)
|
s, _ := a.sessions.Get(req, constants.SeesionName)
|
||||||
s.Values[constants.SessionClaims] = Claims{
|
s.Values[constants.SessionClaims] = Claims{
|
||||||
Sub: "foo",
|
Sub: "foo",
|
||||||
Proxy: ProxyClaims{
|
Proxy: &ProxyClaims{
|
||||||
UserAttributes: map[string]interface{}{
|
UserAttributes: map[string]interface{}{
|
||||||
"username": "foo",
|
"username": "foo",
|
||||||
"password": "bar",
|
"password": "bar",
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (a *Application) configureProxy() error {
|
||||||
func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) {
|
func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) {
|
||||||
return func(r *http.Request) {
|
return func(r *http.Request) {
|
||||||
claims, _ := a.getClaims(r)
|
claims, _ := a.getClaims(r)
|
||||||
if claims.Proxy.BackendOverride != "" {
|
if claims.Proxy != nil && claims.Proxy.BackendOverride != "" {
|
||||||
u, err := url.Parse(claims.Proxy.BackendOverride)
|
u, err := url.Parse(claims.Proxy.BackendOverride)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.log.WithField("backend_override", claims.Proxy.BackendOverride).WithError(err).Warning("failed parse user backend override")
|
a.log.WithField("backend_override", claims.Proxy.BackendOverride).WithError(err).Warning("failed parse user backend override")
|
||||||
|
|
Reference in a new issue