Skip to content

Commit

Permalink
return error for malformed xml to avoid panic, fix external link bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jackHay22 committed Oct 30, 2023
1 parent 9b90e35 commit 17f0fe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion routers/web/auth/linkaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func LinkAccountPostRegister(ctx *context.Context) {
Name: form.UserName,
Email: form.Email,
Passwd: form.Password,
LoginType: auth.OAuth2,
LoginType: authSource.Type,
LoginSource: authSource.ID,
LoginName: linkUser.GothUser.UserID,
}
Expand Down
5 changes: 5 additions & 0 deletions services/auth/source/saml/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/x509"
"encoding/base64"
"encoding/xml"
"errors"
"fmt"
"net/url"

Expand Down Expand Up @@ -86,6 +87,10 @@ func (source *Source) initSAMLSp() error {
Roots: []*x509.Certificate{},
}

if metadata.IDPSSODescriptor == nil {
return errors.New("saml idp metadata missing IDPSSODescriptor")
}

for _, kd := range metadata.IDPSSODescriptor.KeyDescriptors {
for idx, xcert := range kd.KeyInfo.X509Data.X509Certificates {
if xcert.Data == "" {
Expand Down

0 comments on commit 17f0fe5

Please sign in to comment.