Skip to content

Commit

Permalink
Fix OIDC callback if name claim is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Apr 6, 2022
1 parent 1cbe7b1 commit a66d984
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pkg/authnz/authconfig/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"strings"
"time"

"github.com/coreos/go-oidc"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/freifunkMUC/wg-access-server/pkg/authnz/authruntime"
"github.com/freifunkMUC/wg-access-server/pkg/authnz/authsession"
"github.com/freifunkMUC/wg-access-server/pkg/authnz/authutil"

"github.com/coreos/go-oidc"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"gopkg.in/Knetic/govaluate.v2"
Expand Down Expand Up @@ -138,14 +139,18 @@ func (c *OIDCConfig) callbackHandler(runtime *authruntime.ProviderRuntime, oauth
}
}

identity := &authsession.Identity{
Provider: c.Name,
Subject: info.Subject,
Email: info.Email,
Claims: *claims,
}
if name, ok := oidcProfileData["name"].(string); ok {
identity.Name = name
}

err = runtime.SetSession(w, r, &authsession.AuthSession{
Identity: &authsession.Identity{
Provider: c.Name,
Subject: info.Subject,
Email: info.Email,
Name: oidcProfileData["name"].(string),
Claims: *claims,
},
Identity: identity,
})
if err != nil {
http.Error(w, err.Error(), http.StatusUnauthorized)
Expand Down

0 comments on commit a66d984

Please sign in to comment.