public async Task <IActionResult> Index()
        {
            var cookieJar = new CookieJar();//get cookie jar form db
            await _authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            return(View());
        }
Exemple #2
0
        public async Task <IActionResult> Open()
        {
            var cookieJar = new CookieJar(); // Antes de permitir acesso pegue as infos do banco ou de um objeto.
            await _authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            return(View());
        }
        public async Task <IActionResult> Open()
        {
            var cookieJar = new CookieJar();
            await _authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            return(View());
        }
        public async Task <IActionResult> Open()
        {
            var cookieJar = new CookieJar(); // get cookie jar from database
            await _authorizationService.AuthorizeAsync(User, null, CookieJarAuthOperations.Open);

            return(View());
        }
        public async Task <IActionResult> Open()
        {
            var cookieJar = new CookieJar();  // get from db
            //var requirement=new OperationAuthorizationRequirement()
            //{
            //    Name = CookieJarOperations.Open
            //};
            await authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            return(View());
        }
        public async Task <IActionResult> Open()
        {
            CookieJar cookieJar   = new CookieJar(); // get cookiejar from db
            var       requirement = new OperationAuthorizationRequirement()
            {
                Name = CookieJarOperations.Open
            };

            await _authorizationService.AuthorizeAsync(User, cookieJar, requirement);

            return(View());
        }
Exemple #7
0
        public async Task <IActionResult> Open()
        {
            // Get resource from DB
            CookieJar jar = new CookieJar()
            {
                Name = "Ben&Jerrys"
            };
            // Check authorization
            AuthorizationResult result = await _authorizationService.AuthorizeAsync(HttpContext.User, jar, CookieJarAuthRequirements.Open);

            return(View());
        }
        public async Task <IActionResult> Open([FromServices] IAuthorizationService authorizationService)
        {
            var cookieJar = new CookieJar();

            var result = await authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            if (!result.Succeeded)
            {
                return(StatusCode(400));
            }

            return(View());
        }
Exemple #9
0
        //we pass the resource which like password or something else with pass the authorization operation
        //with the user and we can then apply authorization operation to check if with these three params
        //if he authorized or not

        //three params:
        //1-User
        //2-Resources
        //3-requirement : claims
        public async Task <IActionResult> Open()
        {
            var cookieJar = new CookieJar();  //get cookie jar from db
            //we assign requirement in this way
            var requirement = new OperationAuthorizationRequirement()
            {
                Name = CookieJarOperations.Open
            };
            await _authorizationService.AuthorizeAsync(User, cookieJar, requirement);

            //or with shorter way
            await _authorizationService.AuthorizeAsync(User, cookieJar, CookieJarAuthOperations.Open);

            return(View());
        }
        public async Task <IActionResult> Open()
        {
            //create new requirement that will get handled by the handler which is injected by the middleware
            var cookieJar = new CookieJar
            {
                Name = "SomeName"
            }; //this resource could be retrieve from the DB

            //what operation the user is trying to perform on the resource
            var requirement = new OperationAuthorizationRequirement()
            {
                Name = CookieJarOperations.Open
            };

            var result = await _authService.AuthorizeAsync(User, cookieJar, requirement);

            if (!result.Succeeded)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }