Base solution for your next web application

Activities of "bbakermmc"

We created our own attribute/filter for swagger. It will show the endpoint the user has permissions too. You should be able to adapt it to show none :D

public class SwaggerAbpAuthorizeAttributeAuthorizationFilter : IDocumentFilter
    {
        private readonly IPermissionChecker _permissionChecker;

        public SwaggerAbpAuthorizeAttributeAuthorizationFilter(IPermissionChecker permissionChecker)
        {
            _permissionChecker = permissionChecker;
        }

        public void Apply(SwaggerDocument swaggerDoc, DocumentFilterContext context)
        {
            var descriptions = context.ApiDescriptionsGroups.Items.SelectMany(group => group.Items);

            foreach (var description in descriptions)
            {
                var route = "/" + description.RelativePath.TrimEnd('/');
                var path = swaggerDoc.Paths[route];

                var controllerAbpAuthorizeAttributes = description.ControllerAttributes()
                    .OfType<AbpAuthorizeAttribute>().ToList();

                var actionAbpAuthorizeAttributes = description.ActionAttributes()
                    .OfType<AbpAuthorizeAttribute>().ToList();

                var hideSwaggerList = description.ActionAttributes()
                    .OfType<SwaggerHide>().ToList();

                var isHideSwagger = hideSwaggerList.Any();
                
                if (isHideSwagger)
                {
                    swaggerDoc.Paths.Remove(route);
                }

                var authAttributes = new List<AbpAuthorizeAttribute>();

                if (actionAbpAuthorizeAttributes.Count > 0)
                    authAttributes = actionAbpAuthorizeAttributes;
                else if (controllerAbpAuthorizeAttributes.Count > 0)
                    authAttributes = controllerAbpAuthorizeAttributes;

                // check if this action should be visible
                var forbiddenDuePermissions = IsForbiddenDuePermissions(authAttributes);

                if (!forbiddenDuePermissions)
                    continue; // user passed all permissions checks

                // remove method or entire path (if there are no more methods in this path)
                switch (description.HttpMethod)
                {
                    case "DELETE":
                        path.Delete = null;
                        break;
                    case "GET":
                        path.Get = null;
                        break;
                    case "HEAD":
                        path.Head = null;
                        break;
                    case "OPTIONS":
                        path.Options = null;
                        break;
                    case "PATCH":
                        path.Patch = null;
                        break;
                    case "POST":
                        path.Post = null;
                        break;
                    case "PUT":
                        path.Put = null;
                        break;
                    default: throw new ArgumentOutOfRangeException("Method name not mapped to operation");
                }

                if (path.Delete == null && path.Get == null &&
                    path.Head == null && path.Options == null &&
                    path.Patch == null && path.Post == null && path.Put == null)
                    swaggerDoc.Paths.Remove(route);

                
            }
        }

        private bool IsForbiddenDuePermissions(IEnumerable<AbpAuthorizeAttribute> attributes)
        {
            var authorizeAttributes = attributes
                .Where(p => p.Permissions != null).ToList();

            var permissions = new List<string>();
            if (authorizeAttributes.Count != 0)
                foreach (var authorizeAttribute in authorizeAttributes)
                    permissions.AddRange(authorizeAttribute.Permissions.ToList());
            else
                return true;

            foreach (var permission in permissions)
            {
                var allow = _permissionChecker.IsGranted(permission);
                if (allow)
                    return false;
            }

            return true;
        }
    }
Answer

post the error messaage. its probaly in the audit log, but doesnt google need creds for SMTP? dont check use default crads

Join the discussion here: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/657">https://github.com/aspnetzero/aspnet-ze ... issues/657</a> :D

Answer

Why not just make a new method in the repo to return what you want. If your tables have alot of data youre going to return the entire set as a list first then join. Its pretty bad performance.

There is a language cache I think that needs to be cleared. (But not sure why it didn't set your default)

Answer

Can you explain further. I don't think I understand whats not working.

I must of grabbed an old gulpfile.

Just add this. Also in my previous post I commented out the "//if (gutil.env.prod) {" if you dont do this you need to pass "prod" as an additional param in the VSTS gulp config. (I personally like having the min files every time this run and I didnt know of a way for the built in task runner to run with it so I just commented it out)

gulp.task('vstsbuild', ['copy:node_modules'], function () {
    runSequence(['min:css', 'min:js']);
});
Answer

You basically need to restore the npm packages (Right click on the package.json) then run the gulpfile to move the files from the node folder to the lib folder.

Answer
Answer

Why wouldn't you upgrade to v5 now if you have time/resources in its own branch and then when 5.1 comes out you would only need to change some minor things. Waiting until 5.1 only puts your further behind since there are a lot of changes in v5.

Showing 91 to 100 of 145 entries