Ejemplo n.º 1
0
 public object redirectIfNotAuthenticated(ScriptScopeContext scope)
 {
     if (!isAuthenticated(scope))
     {
         var url = AuthenticateAttribute.GetHtmlRedirectUrl(req(scope));
         return(redirectTo(scope, url));
     }
     return(IgnoreResult.Value);
 }
Ejemplo n.º 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
        }
Ejemplo n.º 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
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 9
0
 public static bool IsAuthenticated(this IRequest req) => AuthenticateAttribute.Authenticate(req, req.Dto);
Ejemplo n.º 10
0
        public bool isAuthenticated(ScriptScopeContext scope, string provider)
        {
            var request = req(scope);

            return(request != null && AuthenticateAttribute.Authenticate(request));
        }
Ejemplo n.º 11
0
        public bool isAuthenticated(ScriptScopeContext scope)
        {
            var request = req(scope);

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