Example #1
0
        public ActionResult SignInPost(CustomAccountProviderSignInViewModel model)
        {
            Debug.Assert(model != null);

            if (!ModelState.IsValid)
            {
                return(CustomView(model));
            }

            var returnUrl = new Uri(model.ReturnUrl);

            if (!CustomAccountProviderManager.ValidateReturnUrl(returnUrl))
            {
                return(new HttpUnauthorizedResult());
            }

            // Do validation
            // If the user is in the process of linking his account to another account there is the account provider can be retrieved with GetLinkAccountAccountProvider())
            var accountProvider = (GetAccountProvider() as CustomAccountProvider) ?? GetLinkAccountAccountProvider() as CustomAccountProvider;

            if (accountProvider == null)
            {
                return(new HttpUnauthorizedResult());
            }

            CookieManager.SetCustomAccountProviderValueInCookie("124578895613", new Framework.Cryptography.Identifier(accountProvider.AccountProviderId));

            return(new RedirectResult(returnUrl.AbsoluteUri));
        }
Example #2
0
        /// <summary>
        /// Gets the sign in URL.
        /// </summary>
        /// <param name="returnUrl">The return url.</param>
        /// <param name="state">The state.</param>
        /// <returns>
        /// The sign in url.
        /// </returns>
        public Task <Uri> GetSignInUrlAsync(Uri returnUrl, string state)
        {
            if (returnUrl == null)
            {
                throw new ArgumentNullException(nameof(returnUrl));
            }

            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (CustomAccountProviderManager.ValidateReturnUrl(returnUrl))
            {
                var tenant = CustomAccountProviderManager.GetTenantUrlSegment(HttpContext.Current.Request);

                return(Task.FromResult(
                           new Uri(
                               string.Format(
                                   CultureInfo.InvariantCulture,
                                   string.Format(CultureInfo.InvariantCulture, CustomAccountProviderManagerFactory.CustomAccountProviderLogonUrl, tenant) + "?returnUrl={0}&state={1}",
                                   returnUrl.UrlEncode(),
                                   state.Base64ToBase64Url()))));
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(returnUrl), "Invalid returnUrl");
            }
        }
Example #3
0
        public ActionResult SignIn(string returnUrl, string state)
        {
            if (string.IsNullOrEmpty(returnUrl) || string.IsNullOrEmpty(state))
            {
                return(Redirect(Configuration.HubUrl + "/" + Tenant));
            }

            var accountProvider = (GetAccountProvider() as CustomAccountProvider) ?? GetLinkAccountAccountProvider() as CustomAccountProvider;

            int tenantId         = accountProvider.AccountProviderManager.GetAccountProviderTenant(accountProvider.AccountProviderId).TenantId;
            var customParameters = CustomAccountProviderManager.GetCustomPassedParameters(tenantId);

            return(CustomView(new CustomAccountProviderSignInViewModel()
            {
                ReturnUrl = returnUrl, State = state, CustomParameter = customParameters != null ? customParameters[0] : string.Empty
            }));
        }
Example #4
0
        /// <summary>
        /// Gets the list of claims.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="state">The state.</param>
        /// <returns>
        /// A list of claims for the user.
        /// </returns>
        /// <exception cref="ArgumentNullException">state is <c>null</c> or request is <c>null</c></exception>
        /// <exception cref="UnauthorizedAccessException">
        /// </exception>
        public Task <ICollection <Claim> > GetListOfClaimsAsync(HttpRequestBase request, string state)
        {
            if (string.IsNullOrEmpty(state))
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var tenantId = AccountProviderManager.GetAccountProviderTenant(this.AccountProviderId).TenantId;
            var customPassedParameters = CustomAccountProviderManager.GetCustomPassedParameters(tenantId);

            return(Task.FromResult(CustomAccountProviderManager.CreateUserClaimSet(ConfigurationSettings as CustomAccountProviderConfiguration)));
        }
Example #5
0
        /// <summary>
        /// Gets the sign out URL.
        /// </summary>
        /// <param name="name">The name claim of the user.</param>
        /// <param name="privatePersonalIdentifier">The private personal identifier of the user.</param>
        /// <param name="returnUrl">The return URL.</param>
        /// <returns>
        /// The sign out url.
        /// </returns>
        public Uri GetSignOutUrl(Claim name, Claim privatePersonalIdentifier, Uri returnUrl)
        {
            var tenant = CustomAccountProviderManager.GetTenantUrlSegment(HttpContext.Current.Request);

            return(new Uri(string.Format(CultureInfo.InvariantCulture, CustomAccountProviderManagerFactory.CustomAccountProviderLogOffUrl, tenant, returnUrl.UrlEncode())));
        }