public AuthService GetAuthService()
 {
     var authService = new AuthService {
         RequestContext = new MockRequestContext(),
         ServiceExceptionHandler = (req, ex) =>
             ValidationFeature.HandleException(new BasicResolver(), req, ex)
     };
     return authService;
 }
 static IAppHost GetAppHost()
 {
     if (_appHost == null)
     {
         _appHost = new BasicAppHost();
         var authService = new AuthService();
         authService.SetAppHost(_appHost);
         _appHost.Container.Register(authService);
         _appHost.Container.Register<IAuthSession>(authUserSession);
     }
     return _appHost;
 }
		public static RegistrationService GetRegistrationService(
			IUserAuthRepository userAuthRepository,
			AuthUserSession oAuthUserSession = null,
			MockRequestContext requestContext = null)
		{
			if (requestContext == null)
				requestContext = new MockRequestContext();
			if (oAuthUserSession == null)
				oAuthUserSession = requestContext.ReloadSession();

			var httpReq = requestContext.Get<IHttpRequest>();
			var httpRes = requestContext.Get<IHttpResponse>();
			oAuthUserSession.Id = httpRes.CreateSessionId(httpReq);
			httpReq.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession;

			var mockAppHost = new BasicAppHost {
				Container = requestContext.Container
			};

			requestContext.Container.Register(userAuthRepository);

		    var authService = new AuthService {
                RequestContext = requestContext,
            };
            authService.SetAppHost(mockAppHost);
            mockAppHost.Register(authService);

			var registrationService = new RegistrationService {
				UserAuthRepo = userAuthRepository,
				RequestContext = requestContext,
				RegistrationValidator =
					new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() },
			};
			registrationService.SetAppHost(mockAppHost);

			return registrationService;
		}
Beispiel #4
0
        public virtual bool IsAuthorized(string provider)
        {
            var tokens = ProviderOAuthAccess.FirstOrDefault(x => x.Provider == provider);

            return(AuthService.GetAuthProvider(provider).IsAuthorizedSafe(this, tokens));
        }