예제 #1
0
        public async override Task Invoke(IOwinContext context)
        {
            string user = context.Request.User.Identity.Name;
            string url  = context.Request.Uri.AbsolutePath;

            RoleBasedAuthorization roleauthattr = new RoleBasedAuthorization();

            roleauthattr.Authorize(user, url);
            await Next.Invoke(context);
        }
예제 #2
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            string url    = actionContext.Request.RequestUri.AbsolutePath;
            string userid = actionContext.RequestContext.Principal.Identity.Name;
            RoleBasedAuthorization roleauth = new RoleBasedAuthorization();
            UserRolePermission     result   = roleauth.Authorize(userid, url);

            if (result == null)
            {
                throw new Exception("Not Allow to Access!");
            }
        }