Ejemplo n.º 1
0
        public ActionResult SignUpCallback()
        {
            string tenantId    = Request.QueryString["TenantId"];
            string signupToken = Request.QueryString["signupToken"];

            if (DatabaseIssuerNameRegistry.ContainsTenant(tenantId))
            {
                // The tenant is already registered, show the completion page.
                return(View());
            }

            string consent = Request.QueryString["Consent"];

            if (!String.IsNullOrEmpty(tenantId) &&
                String.Equals(consent, "Granted", StringComparison.OrdinalIgnoreCase))
            {
                // Register the tenant when the permission is granted.
                if (DatabaseIssuerNameRegistry.TryAddTenant(tenantId, signupToken))
                {
                    return(View());
                }
            }

            return(View("Error"));
        }
        private void application_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication)sender;

            ctx = application.Context;
            if (ctx.Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                string wresult = ctx.Request.Form["wresult"];
                if (!string.IsNullOrEmpty(wresult))
                {
                    ResultObject ro = Utility.GetValuesFromWResult(wresult);
                    if (!string.IsNullOrEmpty(ro.TenantId))
                    {
                        if (DatabaseIssuerNameRegistry.TryAddTenant(ro.TenantId, ro.TenantId))
                        {
                            ctx.Response.Redirect("/default.aspx?ISubscriptionToken=" + ro.AccessToken);
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 3
0
        public ActionResult SignUp()
        {
            string signupToken = Guid.NewGuid().ToString();
            string replyUrl    = Url.Action("SignUpCallback", "Tenant", routeValues: new { signupToken = signupToken }, protocol: Request.Url.Scheme);

            DatabaseIssuerNameRegistry.CleanUpExpiredSignupTokens();
            DatabaseIssuerNameRegistry.AddSignupToken(signupToken: signupToken, expirationTime: DateTimeOffset.UtcNow.AddMinutes(5));

            // Redirect to the Active Directory consent page asking for permissions.
            return(new RedirectResult(CreateConsentUrl(
                                          clientId: ClientId,
                                          requestedPermissions: "DirectoryReaders",
                                          consentReturnUrl: replyUrl)));
        }
Ejemplo n.º 4
0
        public static void RefreshValidationSettings()
        {
            string metadataLocation = ConfigurationManager.AppSettings["ida:FederationMetadataLocation"];

            DatabaseIssuerNameRegistry.RefreshKeys(metadataLocation);
        }