mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
feat: escape the avatal URL in CAS response (#3434)
This commit is contained in:
parent
185ab9750a
commit
acc6f3e887
@ -22,6 +22,7 @@ import (
|
|||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -184,6 +185,15 @@ func StoreCasTokenForProxyTicket(token *CasAuthenticationSuccess, targetService,
|
|||||||
return proxyTicket
|
return proxyTicket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func escapeXMLText(input string) (string, error) {
|
||||||
|
var sb strings.Builder
|
||||||
|
err := xml.EscapeText(&sb, []byte(input))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return sb.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func GenerateCasToken(userId string, service string) (string, error) {
|
func GenerateCasToken(userId string, service string) (string, error) {
|
||||||
user, err := GetUser(userId)
|
user, err := GetUser(userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -225,6 +235,11 @@ func GenerateCasToken(userId string, service string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if value != "" {
|
if value != "" {
|
||||||
|
if escapedValue, err := escapeXMLText(value); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else {
|
||||||
|
value = escapedValue
|
||||||
|
}
|
||||||
authenticationSuccess.Attributes.UserAttributes.Attributes = append(authenticationSuccess.Attributes.UserAttributes.Attributes, &CasNamedAttribute{
|
authenticationSuccess.Attributes.UserAttributes.Attributes = append(authenticationSuccess.Attributes.UserAttributes.Attributes, &CasNamedAttribute{
|
||||||
Name: k,
|
Name: k,
|
||||||
Value: value,
|
Value: value,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user