public object redirectIfNotAuthenticated(ScriptScopeContext scope)
 {
     if (!isAuthenticated(scope))
     {
         var url = AuthenticateAttribute.GetHtmlRedirectUrl(req(scope));
         return(redirectTo(scope, url));
     }
     return(IgnoreResult.Value);
 }
예제 #2
0
        public bool isAuthenticated(ScriptScopeContext scope, string provider)
        {
            var request = scope.GetRequest();

#pragma warning disable CS0618
            return(request != null && AuthenticateAttribute.Authenticate(request));

#pragma warning restore CS0618
        }
예제 #3
0
        public bool isAuthenticated(ScriptScopeContext scope)
        {
            var request = scope.GetRequest();

#pragma warning disable CS0618
            return(request != null && AuthenticateAttribute.Authenticate(request, request.GetSession()));

#pragma warning restore CS0618
        }
 public object redirectIfNotAuthenticated(ScriptScopeContext scope, string path)
 {
     if (!isAuthenticated(scope))
     {
         var url = AuthenticateAttribute.GetHtmlRedirectUrl(req(scope), path, includeRedirectParam:true);
         return redirectTo(scope, url);
     }
     
     return IgnoreResult.Value;
 }
예제 #5
0
        public static bool IsAuthorized(this IHasServiceStackProvider hasProvider, AuthenticateAttribute authAttr)
        {
            if (authAttr == null)
            {
                return(true);
            }

            var authSession = hasProvider.ServiceStackProvider.GetSession();

            return(authSession != null && authSession.IsAuthenticated);
        }
예제 #6
0
 public object redirectIfNotAuthenticated(ScriptScopeContext scope)
 {
     if (!isAuthenticated(scope))
     {
         var url = AuthenticateAttribute.GetHtmlRedirectUrl(req(scope));
         return(Context.DefaultMethods.@return(scope, new HttpResult(null, null, HttpStatusCode.Redirect)
         {
             Headers =
             {
                 [HttpHeaders.Location] = url
             }
         }));
     }
     return(IgnoreResult.Value);
 }
예제 #7
0
        public static bool IsAuthenticated(this IRequest req)
        {
            //Sync with [Authenticate] impl
            if (HostContext.HasValidAuthSecret(req))
            {
                return(true);
            }

            var authProviders = AuthenticateService.GetAuthProviders();

            AuthenticateAttribute.PreAuthenticate(req, authProviders);

            var session = req.GetSession();

            return(session != null && authProviders.Any(x => session.IsAuthorized(x.Provider)));
        }
 protected bool Equals(AuthenticateAttribute other)
 {
     return(base.Equals(other) && string.Equals(Provider, other.Provider) && string.Equals(HtmlRedirect, other.HtmlRedirect));
 }
예제 #9
0
 public static bool IsAuthenticated(this IRequest req) => AuthenticateAttribute.Authenticate(req, req.Dto);
예제 #10
0
        public bool isAuthenticated(ScriptScopeContext scope, string provider)
        {
            var request = req(scope);

            return(request != null && AuthenticateAttribute.Authenticate(request));
        }
예제 #11
0
        public bool isAuthenticated(ScriptScopeContext scope)
        {
            var request = req(scope);

            return(request != null && AuthenticateAttribute.Authenticate(request, request.GetSession()));
        }
 protected bool Equals(AuthenticateAttribute other)
 {
     return base.Equals(other) && string.Equals(Provider, other.Provider) && string.Equals(HtmlRedirect, other.HtmlRedirect);
 }
예제 #13
0
 public static Task <bool> IsAuthenticatedAsync(this IRequest req) => AuthenticateAttribute.AuthenticateAsync(req, req.Dto);