public BotAuthenticator(ICredentialProvider credentialProvider, string openIdConfigurationUrl, bool disableEmulatorTokens, EndorsementsValidator validator = null) { if (credentialProvider == null) { throw new ArgumentNullException(nameof(credentialProvider)); } this.credentialProvider = credentialProvider; this.openIdConfigurationUrl = openIdConfigurationUrl; this.disableEmulatorTokens = disableEmulatorTokens; this.validator = validator ?? DefaultEndorsementsValidator; }
public JwtTokenExtractor(TokenValidationParameters tokenValidationParameters, string metadataUrl, string[] allowedSigningAlgorithms, EndorsementsValidator validator) { // Make our own copy so we can edit it _tokenValidationParameters = tokenValidationParameters.Clone(); _tokenValidationParameters.RequireSignedTokens = true; _allowedSigningAlgorithms = allowedSigningAlgorithms; _validator = validator; _openIdMetadata = _openIdMetadataCache.GetOrAdd(metadataUrl, key => { return(new ConfigurationManager <OpenIdConnectConfiguration>(metadataUrl, new OpenIdConnectConfigurationRetriever())); }); _endorsementsData = _endorsementsCache.GetOrAdd(metadataUrl, key => { var retriever = new EndorsementsRetriever(); return(new ConfigurationManager <IDictionary <string, string[]> >(metadataUrl, retriever, retriever)); });; }
public BotAuthenticator(ICredentialProvider credentialProvider, EndorsementsValidator validator = null) : this(credentialProvider, JwtConfig.ToBotFromChannelOpenIdMetadataUrl, false, validator) { }
/// <summary> /// Creates an instance of bot authenticator. /// </summary> /// <param name="microsoftAppId"> The Microsoft app Id.</param> /// <param name="microsoftAppPassword"> The Microsoft app password.</param> /// <param name="validator"> The endorsements validator.</param> /// <remarks> This constructor sets the <see cref="openIdConfigurationUrl"/> to /// <see cref="JwtConfig.ToBotFromChannelOpenIdMetadataUrl"/> and doesn't disable /// the self issued tokens used by emulator. /// </remarks> public BotAuthenticator(string microsoftAppId, string microsoftAppPassword, EndorsementsValidator validator = null) : this(new StaticCredentialProvider(microsoftAppId, microsoftAppPassword), validator) { }
public void UnaffinitizedActivityShouldPass() { var isEndorsed = EndorsementsValidator.Validate(string.Empty, new HashSet <string>(new[] { "right", "wrong" })); isEndorsed.Should().BeTrue(); }
public void EndorsedChannelIdShouldPassWithTwoEndorsements() { var isEndorsed = EndorsementsValidator.Validate("right", new HashSet <string>(new [] { "right", "wrong" })); isEndorsed.Should().BeTrue(); }
public void MismatchedEndorsementsChannelIdShouldFail() { var isEndorsed = EndorsementsValidator.Validate("right", new HashSet <string>(new[] { "wrong" })); isEndorsed.Should().BeFalse(); }
public void UnendorsedChannelIdShouldFail() { var isEndorsed = EndorsementsValidator.Validate("channelOne", new HashSet <string>()); isEndorsed.Should().BeFalse(); }
public void NullEndorsementsParameterShouldThrow() { Action action = () => EndorsementsValidator.Validate("foo", null); action.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("endorsements"); }
public void NullChannelIdParameterShouldPass() { var isEndorsed = EndorsementsValidator.Validate(null, new HashSet <string>()); isEndorsed.Should().BeTrue(); }
public void EndorsedChannelIdShouldPassWithTwoEndorsements() { bool isEndorsed = EndorsementsValidator.Validate("right", new[] { "right", "wrong" }); isEndorsed.Should().BeTrue(); }
public void MismatchedEndorsementsChannelIdShouldFail() { bool isEndorsed = EndorsementsValidator.Validate("right", new[] { "wrong" }); isEndorsed.Should().BeFalse(); }
public void UnendorsedChannelIdShouldFail() { bool isEndorsed = EndorsementsValidator.Validate("channelOne", new string[] { }); isEndorsed.Should().BeFalse(); }
public void NullChannelIdParameterShouldPass() { bool isEndorsed = EndorsementsValidator.Validate(null, new string[] { }); isEndorsed.Should().BeTrue(); }