상속: IApplicationRegistrationService
예제 #1
0
        /// <summary>
        /// This method should not be in production. It is solely used to preconfigure the Windows Azure Access Control Service.
        /// </summary>
        /// <returns></returns>
        public ActionResult ProvisionApplication()
        {
            string clientId = "06B059BE-E8AF-4FD5-A784-833A988A64A0";
            string clientSecret = "AE3A7E6E-DA37-4F99-96A9-70FFCCAACDE1";
            string redirectUri = "http://localhost:3476/Home/Connect/";

            // Register the demo client application
            try
            {
                var x = new ApplicationRegistrationService();
                x.RegisterApplication(clientId, clientSecret, redirectUri, "MyBrewRecipes");

                // Also remove the
                x.RemoveDelegation(clientId, "maartenba", "");
            }
            catch
            {
            }

            // Remove delegation for our test user
            try
            {
                var x = new ApplicationRegistrationService();
                x.RemoveDelegation(clientId, "maartenba", "");
            }
            catch
            {
            }

            return Content("The client_id has been provisioned.");
        }
        public BrokerController()
        {
            _clientId = ConfigurationManager.AppSettings["OAuthClient.Id"];
            _clientSecret = ConfigurationManager.AppSettings["OAuthClient.Secret"];
            _clientRedirectUri = ConfigurationManager.AppSettings["OAuthClient.RedirectUri"];
            _clientName = ConfigurationManager.AppSettings["OAuthClient.Name"];

            _swtSigningKey = ConfigurationManager.AppSettings["WindowsAzure.OAuth.SwtSigningKey"];
            _acsRealm = ConfigurationManager.AppSettings["WindowsAzure.OAuth.RelyingPartyRealm"];
            _registrationService = new ApplicationRegistrationService();
        }
        public ActionResult Register()
        {
            var applicationRegistrationService = new ApplicationRegistrationService();
            try
            {
               //applicationRegistrationService.RemoveApplication("yourclientid");
                applicationRegistrationService.RegisterApplication("yourclientid", "yourclientsecret", "http://yourrealm/", "Just a description");
                            }
            catch
            {
                // Pokemon handler: Gotta catch em all!
            }

            return Content("All set!");
        }
예제 #4
0
        /// <summary>
        /// Index action method. Override if needed but make sure you call <see cref="StoreIncomingRequest"/> in your code.
        /// </summary>
        /// <returns>A <see cref="ViewResult"/>.</returns>
        public virtual ActionResult Index()
        {
            var message = StoreIncomingRequest(HttpContext);

            string errorCode        = "";
            string errorDescription = "";

            if (!ApplicationRegistrationService.ValidateIncomingRequest(message, out errorCode, out errorDescription))
            {
                return(Redirect(message.GetErrorResponseUri(errorCode, errorDescription)));
            }
            if (ApplicationRegistrationService.DelegationExists(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]))
            {
                return(Index_Post(new AuthorizationServerViewModel {
                    Authorize = true
                }));
            }

            return(View("_AuthorizationServer", BuildModel(message)));
        }
예제 #5
0
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = TempData[OauthMessageKey] as OAuthMessage;

            if (model.Authorize)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "The end user has denied consent to access the requested resource")));
            }
        }
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = StoreIncomingRequest(HttpContext);

            if (message != null && message.Parameters[OAuthConstants.GrantType] == OAuthConstants.AccessGrantType.ClientCredentials)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.UnsupportedGrantType, "The provided grant type is not supported by this endpoint")));
            }
        }