Skip to content

Commit

Permalink
Move validation to separate ValidateAssertionInfo func (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
erka authored Oct 12, 2020
1 parent 7b7b80d commit a6b92cd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions retrieve_assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
// limitations under the License.
package saml2

import "fmt"
import (
"fmt"

"github.com/russellhaering/gosaml2/types"
)

//ErrMissingElement is the error type that indicates an element and/or attribute is
//missing. It provides a structured error that can be more appropriately acted
Expand Down Expand Up @@ -46,14 +50,18 @@ func (e ErrMissingElement) Error() string {
//RetrieveAssertionInfo takes an encoded response and returns the AssertionInfo
//contained, or an error message if an error has been encountered.
func (sp *SAMLServiceProvider) RetrieveAssertionInfo(encodedResponse string) (*AssertionInfo, error) {
assertionInfo := &AssertionInfo{
Values: make(Values),
}

response, err := sp.ValidateEncodedResponse(encodedResponse)
if err != nil {
return nil, ErrVerification{Cause: err}
}
return sp.ValidateAssertionInfo(response)
}

func (sp *SAMLServiceProvider) ValidateAssertionInfo(response *types.Response) (*AssertionInfo, error) {
assertionInfo := &AssertionInfo{
Values: make(Values),
}

// TODO: Support multiple assertions
if len(response.Assertions) == 0 {
Expand Down

0 comments on commit a6b92cd

Please sign in to comment.