public SingleSignOnController( ISingleSignOnHandler singleSignOnHandler, IEntityDescriptorStore entityDescriptorStore, IOptions <SamlIdpOptions> options) { _singleSignOnHandler = singleSignOnHandler; _entityDescriptorStore = entityDescriptorStore; _options = options.Value; }
public SingleSignOnHandler( IEntityDescriptorStore entityDescriptorStore, IRelyingPartyRepository relyingPartyRepository, IEnumerable <IAuthenticator> authenticators, IUserRepository userRepository, IOptions <SamlIdpOptions> options) { _entityDescriptorStore = entityDescriptorStore; _relyingPartyRepository = relyingPartyRepository; _authenticators = authenticators; _userRepository = userRepository; _options = options.Value; }
public async Task <string> GetAssertionLocation(IEntityDescriptorStore entityDescriptorStore, string binding, CancellationToken cancellationToken) { var ssp = await GetSpSSODescriptor(entityDescriptorStore, cancellationToken); var assertionConsumerService = ssp.AssertionConsumerService.FirstOrDefault(a => a.Binding == binding); if (assertionConsumerService == null) { return(null); } return(assertionConsumerService.Location); }
protected async Task <SPSSODescriptorType> GetSpSSODescriptor(IEntityDescriptorStore entityDescriptorStore, CancellationToken cancellationToken) { var entityDescriptor = await entityDescriptorStore.Get(MetadataUrl, cancellationToken); var ssp = entityDescriptor.Items.FirstOrDefault(i => i is SPSSODescriptorType) as SPSSODescriptorType; if (ssp == null) { throw new SamlException(System.Net.HttpStatusCode.BadRequest, Saml.Constants.StatusCodes.Requester, Global.BadRelyingPartySpMetadata); } return(ssp); }
public async Task <IEnumerable <X509Certificate2> > GetSigningCertificates(IEntityDescriptorStore entityDescriptorStore, CancellationToken cancellationToken) { var ssp = await GetSpSSODescriptor(entityDescriptorStore, cancellationToken); var result = new List <X509Certificate2>(); foreach (var keyDescriptor in ssp.KeyDescriptor.Where(k => k.use == KeyTypes.signing)) { var x509 = keyDescriptor.KeyInfo.Items.FirstOrDefault(i => i is X509DataType) as X509DataType; if (x509 == null || !x509.ItemsElementName.Any(i => i == ItemsChoiceType.X509Certificate)) { continue; } var index = Array.IndexOf(x509.ItemsElementName, ItemsChoiceType.X509Certificate); var payload = x509.Items[index] as byte[]; result.Add(new X509Certificate2(payload)); } return(result); }
public async Task <bool> GetAuthnRequestsSigned(IEntityDescriptorStore entityDescriptorStore, CancellationToken cancellationToken) { var ssp = await GetSpSSODescriptor(entityDescriptorStore, cancellationToken); return(ssp.AuthnRequestsSignedSpecified && ssp.AuthnRequestsSigned); }