Ejemplo n.º 1
0
        /// <summary>
        /// Called when the request is unauthenticated.
        /// </summary>
        /// <param name="context">Context object which carries the HTTP request message to send to the server and the empty HTTP response property.</param>
        protected virtual void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
        {
            HttpResponseMessage unauthorizedResponseMessage = context.Request.CreateResponse(HttpStatusCode.Unauthorized);

            unauthorizedResponseMessage.Headers.Add("WWW-Authenticate", _httpBasicSchemeName);
            context.Response = unauthorizedResponseMessage;
        }
        private Task <HttpResponseMessage> HandleUnauthenticatedRequestImpl(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            try {
                var unauthanticatedRequestContext = new UnauthenticatedRequestContext(request);
                HandleUnauthenticatedRequest(unauthanticatedRequestContext);

                if (unauthanticatedRequestContext.Response != null)
                {
                    EnsureRequestMessageExistence(unauthanticatedRequestContext.Response, request);
                    return(TaskHelpers.FromResult <HttpResponseMessage>(unauthanticatedRequestContext.Response));
                }

                return(base.SendAsync(request, cancellationToken));
            }
            catch (Exception e) {
                return(TaskHelpers.FromError <HttpResponseMessage>(e));
            }
        }
Ejemplo n.º 3
0
        private Task <HttpResponseMessage> HandleUnauthenticatedRequestImpl(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            try
            {
                UnauthenticatedRequestContext unauthanticatedRequestContext = new UnauthenticatedRequestContext(request);
                HandleUnauthenticatedRequest(unauthanticatedRequestContext);

                if (unauthanticatedRequestContext.Response != null)
                {
                    EnsureRequestMessageExistence(unauthanticatedRequestContext.Response, request);
                    return(Task.FromResult <HttpResponseMessage>(unauthanticatedRequestContext.Response));
                }

                return(base.SendAsync(request, cancellationToken));
            }
            catch (Exception e)
            {
                TaskCompletionSource <HttpResponseMessage> tcs = new TaskCompletionSource <HttpResponseMessage>();
                tcs.SetException(e);
                return(tcs.Task);
            }
        }
 protected override void HandleUnauthenticatedRequest(
     UnauthenticatedRequestContext context)
 {
     context.Response = new HttpResponseMessage(HttpStatusCode.Ambiguous);
 }
 protected override void HandleUnauthenticatedRequest(
     UnauthenticatedRequestContext context)
 {
 }
        protected override void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
        {
            var response = context.Request.CreateResponse(HttpStatusCode.Redirect);

            response.Headers.Location = new Uri("http://facebook.com");
        }
 /// <summary>
 /// Called when the request is unauthenticated.
 /// </summary>
 /// <param name="context">Context object which carries the HTTP request message to send to the server and the empty HTTP response property.</param>
 protected virtual void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
 {
     HttpResponseMessage unauthorizedResponseMessage = context.Request.CreateResponse(HttpStatusCode.Unauthorized);
     unauthorizedResponseMessage.Headers.Add("WWW-Authenticate", _httpBasicSchemeName);
     context.Response = unauthorizedResponseMessage;
 }
        private Task<HttpResponseMessage> HandleUnauthenticatedRequestImpl(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            try {

                var unauthanticatedRequestContext = new UnauthenticatedRequestContext(request);
                HandleUnauthenticatedRequest(unauthanticatedRequestContext);

                if (unauthanticatedRequestContext.Response != null) {

                    EnsureRequestMessageExistence(unauthanticatedRequestContext.Response, request);
                    return TaskHelpers.FromResult<HttpResponseMessage>(unauthanticatedRequestContext.Response);
                }

                return base.SendAsync(request, cancellationToken);
            }
            catch (Exception e) {

                return TaskHelpers.FromError<HttpResponseMessage>(e);
            }
        }
Ejemplo n.º 9
0
 protected override void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
 {
     // Do nothing here. The Autharization
     // will be handled by the AuthorizeAttribute.
 }
Ejemplo n.º 10
0
 protected override void HandleUnauthenticatedRequest(
     UnauthenticatedRequestContext context)
 {
 }
Ejemplo n.º 11
0
 protected override void HandleUnauthenticatedRequest(
     UnauthenticatedRequestContext context)
 {
     context.Response = new HttpResponseMessage(HttpStatusCode.Ambiguous);
 }
Ejemplo n.º 12
0
 protected override void HandleUnauthenticatedRequest(UnauthenticatedRequestContext context)
 {
     // Do nothing here to keep going inside the pipeline and let the AuthorizeAttribute handle authorization.
     // Useful when you allow anonymous access for some of your endpoints.
 }
        private Task<HttpResponseMessage> HandleUnauthenticatedRequestImpl(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            try
            {
                UnauthenticatedRequestContext unauthanticatedRequestContext = new UnauthenticatedRequestContext(request);
                HandleUnauthenticatedRequest(unauthanticatedRequestContext);

                if (unauthanticatedRequestContext.Response != null)
                {
                    EnsureRequestMessageExistence(unauthanticatedRequestContext.Response, request);
                    return Task.FromResult<HttpResponseMessage>(unauthanticatedRequestContext.Response);
                }

                return base.SendAsync(request, cancellationToken);
            }
            catch (Exception e)
            {
                TaskCompletionSource<HttpResponseMessage> tcs = new TaskCompletionSource<HttpResponseMessage>();
                tcs.SetException(e);
                return tcs.Task;
            }
        }