示例#1
0
        public void Should_Return_WWW_Authenticate_Header_In_Options()
        {
            //Given
            var options = new StatelessAuthOptions()
            {
                IgnorePaths = Enumerable.Empty <string>(),
                WWWAuthenticateChallenge = "Basic"
            };

            var owinhttps = GetStatelessAuth(GetNextFunc(), statelessAuthOptions: options);

            var environment = new Dictionary <string, object>
            {
                { "owin.RequestHeaders", new Dictionary <string, string[]>() },
                { "owin.RequestPath", "/" }
            };

            //When
            var task = owinhttps.Invoke(environment);

            var responseHeaders = (IDictionary <string, string[]>)environment["owin.ResponseHeaders"];

            //Then
            Assert.Equal("Basic", responseHeaders["WWW-Authenticate"].First());
        }
 public StatelessAuth GetStatelessAuth(Func<IDictionary<string, object>, Task> nextFunc, ITokenValidator tokenValidator = null, StatelessAuthOptions statelessAuthOptions = null)
 {
     tokenValidator = tokenValidator ?? GetFakeTokenValidator();
     statelessAuthOptions = statelessAuthOptions ?? GetStatelessAuthOptions();
     return new StatelessAuth(nextFunc, tokenValidator, statelessAuthOptions);
 }
        public void Should_Return_WWW_Authenticate_Header_In_Options()
        {
            //Given
            var options = new StatelessAuthOptions()
            {
                IgnorePaths = Enumerable.Empty<string>(),
                WWWAuthenticateChallenge = "Basic"
            };

            var owinhttps = GetStatelessAuth(GetNextFunc(), statelessAuthOptions: options);
            
            var environment = new Dictionary<string, object>
            {
                {"owin.RequestHeaders", new Dictionary<string, string[]>() },
                {"owin.RequestPath", "/"}
            };

            //When
            var task = owinhttps.Invoke(environment);

            var responseHeaders = (IDictionary<string, string[]>)environment["owin.ResponseHeaders"];

            //Then
            Assert.Equal("Basic", responseHeaders["WWW-Authenticate"].First());
        }
 public static IAppBuilder RequiresStatelessAuth(this IAppBuilder app, ITokenValidator tokenValidator, StatelessAuthOptions options = null)
 {
     return app.Use<StatelessAuth>(tokenValidator, options);
 }
示例#5
0
 public StatelessAuth GetStatelessAuth(Func <IDictionary <string, object>, Task> nextFunc, ITokenValidator tokenValidator = null, StatelessAuthOptions statelessAuthOptions = null)
 {
     tokenValidator       = tokenValidator ?? GetFakeTokenValidator();
     statelessAuthOptions = statelessAuthOptions ?? GetStatelessAuthOptions();
     return(new StatelessAuth(nextFunc, tokenValidator, statelessAuthOptions));
 }
示例#6
0
 public static IAppBuilder RequiresStatelessAuth(this IAppBuilder app, ITokenValidator tokenValidator, StatelessAuthOptions options = null)
 {
     return(app.Use <StatelessAuth>(tokenValidator, options));
 }