public void OnAuthorization(AuthorizationFilterContext context)
        {
            var request = context.HttpContext.Request;

            if (!request.Headers.ContainsKey("Token"))
            {
                context.Result = new UnauthorizedResult();
                return;
            }

            AuthenticateMethod2 method2 = new AuthenticateMethod2();
            string token = request.Headers["Token"];

            if (!method2.ValidateToken(token))
            {
                context.Result = new UnauthorizedResult();
                return;
            }

            if (!string.IsNullOrEmpty(Roles))
            {
                string rolToken = method2.GetRol(token);

                if (!ValidateRol(rolToken))
                {
                    context.Result = new UnauthorizedResult();
                }
            }
        }
예제 #2
0
 public SecurityController(AunthenticateMethod1 _method1, AuthenticateMethod2 _method2)
 {
     method1 = _method1;
     method2 = _method2;
 }