github.com/vmware/go-vcloud-director/v2@v2.24.0/types/v56/saml.go (about) 1 /* 2 * Copyright 2023 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. 3 */ 4 5 package types 6 7 import ( 8 "encoding/xml" 9 "fmt" 10 ) 11 12 // VcdSamlMetadata helps to marshal vCD SAML Metadata endpoint response 13 // https://1.1.1.1/cloud/org/my-org/saml/metadata/alias/vcd 14 type VcdSamlMetadata struct { 15 XMLName xml.Name `xml:"EntityDescriptor"` 16 Xmlns string `xml:"xmlns,attr,omitempty"` 17 Text string `xml:",chardata"` 18 ID string `xml:"ID,attr"` 19 Md string `xml:"xmlns:md,attr,omitempty"` 20 21 // EntityID is the configured vCD Entity ID which is used in ADFS authentication request 22 // Note: once this field is set, it is not possible to change it back to empty, 23 // but only to replace it with a different value 24 EntityID string `xml:"entityID,attr"` 25 // SPSSODescriptor is the main body of the SAML metadata file, which defines what the SAML identity provider can do 26 SPSSODescriptor SPSSODescriptor `xml:"SPSSODescriptor,omitempty"` 27 } 28 29 // SPSSODescriptor is the main body of the SAML metadata file, which defines what the SAML identity provider can do 30 type SPSSODescriptor struct { 31 Ds string `xml:"xmlns:ds,attr,omitempty"` 32 AuthnRequestsSigned bool `xml:"AuthnRequestsSigned,attr"` 33 ProtocolSupportEnumeration string `xml:"protocolSupportEnumeration,attr"` 34 WantAssertionsSigned bool `xml:"WantAssertionsSigned,attr"` 35 KeyDescriptor []struct { 36 Use string `xml:"use,attr"` 37 KeyInfo struct { 38 //Ds string `xml:"xmlns:ds,attr"` 39 X509Data struct { 40 X509Certificate string `xml:"X509Certificate"` 41 } `xml:"X509Data"` 42 } `xml:"KeyInfo"` 43 } `xml:"KeyDescriptor"` 44 45 SingleLogoutService []struct { 46 Binding string `xml:"Binding,attr"` 47 Location string `xml:"Location,attr"` 48 } `xml:"SingleLogoutService"` 49 NameIDFormat []string `xml:"NameIDFormat"` 50 AssertionConsumerService []struct { 51 Binding string `xml:"Binding,attr"` 52 Hoksso string `xml:"xmlns:hoksso,attr"` 53 Index int `xml:"index,attr"` 54 IsDefault bool `xml:"isDefault,attr,omitempty"` 55 Location string `xml:"Location,attr"` 56 ProtocolBinding string `xml:"ProtocolBinding,attr"` 57 } `xml:"AssertionConsumerService"` 58 } 59 60 // AdfsAuthErrorEnvelope helps to parse ADFS authentication error with help of Error() method 61 // 62 // Note. This structure is not complete and has many more fields. 63 type AdfsAuthErrorEnvelope struct { 64 XMLName xml.Name `xml:"Envelope"` 65 Body struct { 66 Text string `xml:",chardata"` 67 Fault struct { 68 Text string `xml:",chardata"` 69 Code struct { 70 Text string `xml:",chardata"` 71 Value string `xml:"Value"` 72 Subcode struct { 73 Text string `xml:",chardata"` 74 Value struct { 75 Text string `xml:",chardata"` 76 A string `xml:"a,attr"` 77 } `xml:"Value"` 78 } `xml:"Subcode"` 79 } `xml:"Code"` 80 Reason struct { 81 Chardata string `xml:",chardata"` 82 Text struct { 83 Text string `xml:",chardata"` 84 Lang string `xml:"lang,attr"` 85 } `xml:"Text"` 86 } `xml:"Reason"` 87 } `xml:"Fault"` 88 } `xml:"Body"` 89 } 90 91 // Error satisfies Go's default `error` interface for AdfsAuthErrorEnvelope and formats 92 // error for humand readable output 93 func (samlErr AdfsAuthErrorEnvelope) Error() string { 94 return fmt.Sprintf("SAML request got error: %s", samlErr.Body.Fault.Reason.Text) 95 } 96 97 // AdfsAuthResponseEnvelope helps to marshal ADFS reponse to authentication request. 98 // 99 // Note. This structure is not complete and has many more fields. 100 type AdfsAuthResponseEnvelope struct { 101 XMLName xml.Name `xml:"Envelope"` 102 Body struct { 103 RequestSecurityTokenResponseCollection struct { 104 RequestSecurityTokenResponse struct { 105 // RequestedSecurityTokenTxt returns data which is accepted by vCD as a SIGN token 106 RequestedSecurityTokenTxt InnerXML `xml:"RequestedSecurityToken"` 107 } `xml:"RequestSecurityTokenResponse"` 108 } `xml:"RequestSecurityTokenResponseCollection"` 109 } `xml:"Body"` 110 } 111 112 // OrgFederationSettings is the structure used to set SAML identity service for an organization 113 type OrgFederationSettings struct { 114 Href string `xml:"href,attr,omitempty" json:"href,omitempty"` 115 Type string `xml:"type,attr,omitempty" json:"type,omitempty"` 116 Link LinkList `xml:"Link,omitempty" json:"link,omitempty"` 117 SAMLMetadata string `xml:"SAMLMetadata" json:"samlMetadata"` 118 Enabled bool `xml:"Enabled" json:"enabled"` 119 CertificateExpiration string `xml:"CertificateExpiration" json:"certificateExpiration"` 120 SigningCertificateExpiration string `xml:"SigningCertificateExpiration" json:"signingCertificateExpiration"` 121 EncryptionCertificateExpiration string `xml:"EncryptionCertificateExpiration" json:"encryptionCertificateExpiration"` 122 SamlSPEntityID string `xml:"SamlSPEntityId" json:"samlSPEntityId"` 123 SamlAttributeMapping struct { // The names of SAML attributes used to populate user profiles. 124 Href string `xml:"href,attr,omitempty" json:"href,omitempty"` 125 Type string `xml:"type,attr,omitempty" json:"type,omitempty"` 126 Link LinkList `xml:"Link,omitempty" json:"link,omitempty"` 127 EmailAttributeName string `xml:"EmailAttributeName,omitempty" json:"emailAttributeName,omitempty"` 128 UserNameAttributeName string `xml:"UserNameAttributeName,omitempty" json:"userNameAttributeName,omitempty"` 129 FirstNameAttributeName string `xml:"FirstNameAttributeName,omitempty" json:"firstNameAttributeName,omitempty"` 130 SurnameAttributeName string `xml:"SurnameAttributeName,omitempty" json:"surnameAttributeName,omitempty"` 131 FullNameAttributeName string `xml:"FullNameAttributeName,omitempty" json:"fullNameAttributeName,omitempty"` 132 GroupAttributeName string `xml:"GroupAttributeName,omitempty" json:"groupAttributeName,omitempty"` 133 RoleAttributeName string `xml:"RoleAttributeName,omitempty" json:"roleAttributeName,omitempty"` 134 } `xml:"SamlAttributeMapping,omitempty" json:"samlAttributeMapping,omitempty"` 135 SigningCertLibraryItemID string `xml:"SigningCertLibraryItemId" json:"signingCertLibraryItemId"` 136 EncryptionCertLibraryItemID string `xml:"EncryptionCertLibraryItemId" json:"encryptionCertLibraryItemID"` 137 }