示例#1
0
        protected override async Task invoke(Func <Task> func)
        {
            if (!_settings.AuthorizationEnabled)
            {
                await func().ConfigureAwait(false);

                return;
            }

            var access = _authorization.IsAuthorized(_context);

            // If authorized, continue to the next behavior in the
            // chain (filters, controller actions, views, etc.)
            if (access == AuthorizationRight.Allow)
            {
                await func().ConfigureAwait(false);
            }
            else
            {
                // If authorization fails, hand off to the failure handler
                // and stop the inner behaviors from executing
                var continuation = _failureHandler.Handle();
                _context.Service <IContinuationProcessor>().Continue(continuation, Inner);
            }
        }
示例#2
0
        protected override DoNext performInvoke()
        {
            var access = _policyExecutor.IsAuthorized(_request, _policies);

            // If authorized, continue to the next behavior in the
            // chain (filters, controller actions, views, etc.)
            if (access == AuthorizationRight.Allow)
            {
                return(DoNext.Continue);
            }

            // If authorization fails, hand off to the failure handler
            // and stop the inner behaviors from executing
            _failureHandler.Handle();
            return(DoNext.Stop);
        }