public ActionResult Provider()
        {
            IRequest request = OpenIdProvider.GetRequest();
            if (request != null)
            {
                // Some requests are automatically handled by DotNetOpenAuth.  If this is one, go ahead and let it go.
                if (request.IsResponseReady)
                {
                    return OpenIdProvider.PrepareResponse(request).AsActionResult();
                }

                // This is apparently one that the host (the web site itself) has to respond to.
                ProviderEndpoint.PendingRequest = (IHostProcessedRequest)request;

                // If PAPE requires that the user has logged in recently, we may be required to challenge the user to log in.
                var papeRequest = ProviderEndpoint.PendingRequest.GetExtension<PolicyRequest>();
                if (papeRequest != null && papeRequest.MaximumAuthenticationAge.HasValue)
                {
                    TimeSpan timeSinceLogin = DateTime.UtcNow - formsAuth.SignedInTimestampUtc.Value;
                    if (timeSinceLogin > papeRequest.MaximumAuthenticationAge.Value)
                    {
                        // The RP wants the user to have logged in more recently than he has.  
                        // We'll have to redirect the user to a login screen.
                        return RedirectToAction("LogOn", "Account", new { returnUrl = Url.Action("ProcessAuthRequest") });
                    }
                }

                return ProcessAuthRequest();
            }
            else
            {
                // No OpenID request was recognized.  This may be a user that stumbled on the OP Endpoint.  
                return View();
            }
        }
Beispiel #2
0
        public ActionResult Provider()
        {
            IRequest request = OpenIdProvider.GetRequest();

            if (request != null)
            {
                // Some requests are automatically handled by DotNetOpenAuth.  If this is one, go ahead and let it go.
                if (request.IsResponseReady)
                {
                    return(OpenIdProvider.PrepareResponse(request).AsActionResult());
                }

                // This is apparently one that the host (the web site itself) has to respond to.
                ProviderEndpoint.PendingRequest = (IHostProcessedRequest)request;

                // Try responding immediately if possible.
                ActionResult response;
                if (this.AutoRespondIfPossible(out response))
                {
                    return(response);
                }

                // We can't respond immediately with a positive result.  But if we still have to respond immediately...
                if (ProviderEndpoint.PendingRequest.Immediate)
                {
                    // We can't stop to prompt the user -- we must just return a negative response.
                    return(this.SendAssertion());
                }

                return(this.RedirectToAction("AskUser"));
            }
            else
            {
                // No OpenID request was recognized.  This may be a user that stumbled on the OP Endpoint.
                return(this.View());
            }
        }
        public ActionResult Provider()
        {
            IRequest request = OpenIdProvider.GetRequest();

            if (request != null)
            {
                var authRequest = request as IAuthenticationRequest;
                if (authRequest != null)
                {
                    PendingAuthenticationRequest = authRequest;
                    if (authRequest.IsReturnUrlDiscoverable(OpenIdProvider) == RelyingPartyDiscoveryResult.Success &&
                        User.Identity.IsAuthenticated &&
                        (authRequest.IsDirectedIdentity || this.UserControlsIdentifier(authRequest)))
                    {
                        return(this.SendAssertion());
                    }
                    else
                    {
                        return(RedirectToAction("LogOn", "Account", new { returnUrl = Url.Action("SendAssertion") }));
                    }
                }

                if (request.IsResponseReady)
                {
                    return(OpenIdProvider.PrepareResponse(request).AsActionResult());
                }
                else
                {
                    return(RedirectToAction("LogOn", "Account"));
                }
            }
            else
            {
                return(View());
            }
        }