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);
        }
 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);