示例#1
0
        private static void OnSendingHeaders(OnSendingHeadersState state, string authenticationMethod)
        {
            AuthenticationHeaderValue challenge = state.Challenge;
            OwinResponse response = state.Response;
            OwinRequest  request  = state.Request;

            if (response.StatusCode != 401)
            {
                return;
            }

            if (!IsAuthenticationMethodEnabled(request, authenticationMethod))
            {
                return;
            }

            AddChallenge(challenge, response);
        }
示例#2
0
        public static bool TryRegisterAddChallengeOnSendingHeaders(AuthenticationHeaderValue challenge,
                                                                   string authenticationMethod, OwinRequest request, OwinResponse response, out string errorMessage)
        {
            Action <Action <object>, object> registerOnSendingHeaders = GetRegisterOnSendingHeaders(request);

            if (registerOnSendingHeaders == null)
            {
                errorMessage = "OnSendingHeaders is not available.";
                return(false);
            }

            OnSendingHeadersState state = new OnSendingHeadersState
            {
                Challenge = challenge,
                Response  = response,
                Request   = request
            };

            registerOnSendingHeaders((untypedState) => OnSendingHeaders((OnSendingHeadersState)untypedState,
                                                                        authenticationMethod), state);

            errorMessage = null;
            return(true);
        }