Beispiel #1
0
        public static string GetHtmlRedirect(this AuthFeature feature)
        {
            if (feature != null)
            {
                return(feature.HtmlRedirect);
            }

            return("~/" + HostContext.ResolveLocalizedString(LocalizedStrings.Login));
        }
        public static bool IsValidUsername(this AuthFeature feature, string userName)
        {
            if (feature == null || feature.IsValidUsernameFn == null)
            {
                return(ValidUserNameRegEx.IsMatch(userName));
            }

            return(feature.IsValidUsernameFn.Invoke(userName));
        }
Beispiel #3
0
        public static bool IsValidUsername(this AuthFeature feature, string userName)
        {
            if (feature == null)
            {
                return(ValidUserNameRegEx.IsMatch(userName));
            }

            return(feature.IsValidUsernameFn != null
                ? feature.IsValidUsernameFn(userName)
                : feature.ValidUserNameRegEx.IsMatch(userName));
        }
Beispiel #4
0
            public override void Configure(Container container)
            {
                var db = new FakeDataStore();
                container.Register<IDataStore>(c => db).ReusedWithin(ReuseScope.Container);
                JsConfig.ExcludeTypeInfo = true;

                var auth = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new RestivalAuthProvider(db) }) {
                    HtmlRedirect = null
                };
                Plugins.Add(auth);
            }
Beispiel #5
0
        private void ConfigureAuth(Container container) {
            container.Register(GetUserSession).ReusedWithin(ReuseScope.Request);
            container.Register(GetUserProfile).ReusedWithin(ReuseScope.Request);
            container.RegisterAutoWiredAs<OrmLiteAuthRepository, IAuthRepository>().ReusedWithin(ReuseScope.Request);
            container.RegisterAutoWiredAs<OrmLiteAuthRepository, IUserAuthRepository>().ReusedWithin(ReuseScope.Request);

            var auth_providers = new IAuthProvider[] { new CredentialsAuthProvider() };
            var auth_feature = new AuthFeature(() => new BoilerUserSession(), auth_providers) {
                HtmlRedirect = "/index.html"
            };
            Plugins.Add(auth_feature);
        }
            public override void Configure(Container container)
            {
                Func<string, string> localize = s => HostContext.AppHost.ResolveLocalizedString(s, null);
                Plugins.Add(new SessionFeature());
                SetConfig(new HostConfig(){AllowSessionIdsInHttpParams = true});

                var appSettings = new AppSettings();

                var authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new CredentialsAuthProvider{ SkipPasswordVerificationForInProcessRequests = true }, new FacebookAuthProvider(appSettings) }) { HtmlRedirect = null };
                authFeature.IncludeAssignRoleServices = false;

                Plugins.Add(new ServerEventsFeature()
                {
                    LimitToAuthenticatedUsers = true,
                    NotifyChannelOfSubscriptions = false,
                });
                Plugins.Add(new RegistrationFeature());
                Plugins.Add(authFeature);
                var authRepo = new InMemoryAuthRepository();
                container.Register<IUserAuthRepository>(authRepo);
                authRepo.CreateUserAuth(new UserAuth() { UserName = "******" }, "testpassword");
            }