func (c *samlRoleClient) CredentialsWithContext(ctx context.Context) (*credentials.Credentials, error) {
	v, err := c.awsCredCache.Retrieve(ctx)
	if err != nil {
		var saml *credentials.SamlAssertion
		saml, err = c.samlClient.SamlAssertionWithContext(ctx)
		if err != nil {
			return nil, err
		}
		c.roleProvider.SamlAssertion(saml)
		v, err = c.awsCredCache.Retrieve(ctx)
		if err != nil {
			return nil, err
		}
	}
	cred := &credentials.Credentials{
		AccessKeyId:     v.AccessKeyID,
		SecretAccessKey: v.SecretAccessKey,
		Token:           v.SessionToken,
		Expiration:      v.Expires,
		ProviderName:    v.Source,
	}
	return cred, nil
}
CredentialsWithContext is the implementation of the CredentialClient interface for retrieving temporary AWS
credentials using the Assume Role with SAML operation.
package client
import (
	"context"
	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/mmmorris1975/aws-runas/client/external"
	"github.com/mmmorris1975/aws-runas/credentials"
	"github.com/mmmorris1975/aws-runas/identity"
	"time"
)
type samlRoleClient struct {
	samlClient   external.SamlClient
	roleProvider credentials.SamlRoleProvider
	awsCredCache *aws.CredentialsCache
	session      aws.Config
}
type SamlRoleClientConfig struct {
	external.AuthenticationClientConfig
	Cache    credentials.CredentialCacher
	Duration time.Duration
	RoleArn  string
}
func NewSamlRoleClient(cfg aws.Config, url string, clientCfg *SamlRoleClientConfig) *samlRoleClient {
	p := credentials.NewSamlRoleProvider(cfg, clientCfg.RoleArn, new(credentials.SamlAssertion))
	p.Duration = clientCfg.Duration
	p.Cache = clientCfg.Cache
	p.Logger = clientCfg.Logger
	cfg.Credentials = p
	return &samlRoleClient{
		samlClient:   external.MustGetSamlClient(clientCfg.IdentityProviderName, url, clientCfg.AuthenticationClientConfig),
		roleProvider: p,
		session:      cfg,
		awsCredCache: aws.NewCredentialsCache(p, func(o *aws.CredentialsCacheOptions) {
			o.ExpiryWindow = p.ExpiryWindow
		}),
	}
}
func (c *samlRoleClient) Identity() (*identity.Identity, error) {
	return c.samlClient.Identity()
}
func (c *samlRoleClient) Roles() (*identity.Roles, error) {
	roles, err := c.samlClient.Roles()
	if err != nil {
		var saml *credentials.SamlAssertion
		saml, err = c.samlClient.SamlAssertion()
		if err != nil {
			return nil, err
		}
		c.roleProvider.SamlAssertion(saml)
		roles, err = c.samlClient.Roles()
	}
	return roles, err
}
func (c *samlRoleClient) Credentials() (*credentials.Credentials, error) {
	return c.CredentialsWithContext(context.Background())
}