support CAS identity provider

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2021-02-05 15:20:37 +08:00
parent 2d73e777f4
commit 5f0727cf34
27 changed files with 1853 additions and 3 deletions

95
vendor/gopkg.in/cas.v2/xml_service_response.go generated vendored Normal file
View File

@@ -0,0 +1,95 @@
package cas
import (
"encoding/xml"
"time"
)
type xmlServiceResponse struct {
XMLName xml.Name `xml:"http://www.yale.edu/tp/cas serviceResponse"`
Failure *xmlAuthenticationFailure
Success *xmlAuthenticationSuccess
}
type xmlAuthenticationFailure struct {
XMLName xml.Name `xml:"authenticationFailure"`
Code string `xml:"code,attr"`
Message string `xml:",innerxml"`
}
type xmlAuthenticationSuccess struct {
XMLName xml.Name `xml:"authenticationSuccess"`
User string `xml:"user"`
ProxyGrantingTicket string `xml:"proxyGrantingTicket,omitempty"`
Proxies *xmlProxies `xml:"proxies"`
Attributes *xmlAttributes `xml:"attributes"`
ExtraAttributes []*xmlAnyAttribute `xml:",any"`
}
type xmlProxies struct {
XMLName xml.Name `xml:"proxies"`
Proxies []string `xml:"proxy"`
}
func (p *xmlProxies) AddProxy(proxy string) {
p.Proxies = append(p.Proxies, proxy)
}
type xmlAttributes struct {
XMLName xml.Name `xml:"attributes"`
AuthenticationDate time.Time `xml:"authenticationDate"`
LongTermAuthenticationRequestTokenUsed bool `xml:"longTermAuthenticationRequestTokenUsed"`
IsFromNewLogin bool `xml:"isFromNewLogin"`
MemberOf []string `xml:"memberOf"`
UserAttributes *xmlUserAttributes
ExtraAttributes []*xmlAnyAttribute `xml:",any"`
}
type xmlUserAttributes struct {
XMLName xml.Name `xml:"userAttributes"`
Attributes []*xmlNamedAttribute `xml:"attribute"`
AnyAttributes []*xmlAnyAttribute `xml:",any"`
}
type xmlNamedAttribute struct {
XMLName xml.Name `xml:"attribute"`
Name string `xml:"name,attr,omitempty"`
Value string `xml:",innerxml"`
}
type xmlAnyAttribute struct {
XMLName xml.Name
Value string `xml:",chardata"`
}
func (xsr *xmlServiceResponse) marshalXML(indent int) ([]byte, error) {
if indent == 0 {
return xml.Marshal(xsr)
}
indentStr := ""
for i := 0; i < indent; i++ {
indentStr += " "
}
return xml.MarshalIndent(xsr, "", indentStr)
}
func failureServiceResponse(code, message string) *xmlServiceResponse {
return &xmlServiceResponse{
Failure: &xmlAuthenticationFailure{
Code: code,
Message: message,
},
}
}
func successServiceResponse(username, pgt string) *xmlServiceResponse {
return &xmlServiceResponse{
Success: &xmlAuthenticationSuccess{
User: username,
ProxyGrantingTicket: pgt,
},
}
}