Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host administration access #2202

Closed
duard-sf opened this issue Nov 18, 2019 · 5 comments
Closed

Host administration access #2202

duard-sf opened this issue Nov 18, 2019 · 5 comments
Labels

Comments

@duard-sf
Copy link

When logged in as the default host admin (admin@abp.io, 1q2w3E*), I am not able to see tenant users. I.e., the /api/identity/users endpoint returns only users whose tenant ID is also null, excluding users who indeed have a tenant ID.

Should I be creating functionality for this myself, like creating repositories that disable the multi-tenancy filter based on the user's role? Or, what is the correct way to handle this?

Basically, I need a "super admin" role that can do CRUD on all entities for all tenants.

@pranavpatil19
Copy link

i think this is great idea

@scharada
Copy link

this has been discussed in paid project repo. in fact it's not only the superadmin feature, but also shared Entities that should be seen by all tenants and stored in one shared database only. the team said they would implement it but never did. in fact, it is one of the reasons i stopped using the paid framework.
these are a basic scenario in SaaS business ... they just did not want to see it and instead, they concentrated on other minor changes that are often less important and not so critical.
Sorry for the not so positive comment but that is the truth. at least for my case.

@duard-sf
Copy link
Author

Thanks for the feedback. So I guess the only solution at the moment is to implement this manually.

@goxiaoy
Copy link
Contributor

goxiaoy commented Dec 26, 2019

This is only possible when different tenant share the same database.

In my case, I create a middleware to disable multitenant datafilter when 'super admin' is detected.

            app.UseMultiTenancy();
            app.UseMiddleware<HostSideDisableTenantFilterMiddleware>();
public class HostSideDisableTenantFilterMiddleware
    {
        private readonly RequestDelegate _next;
        private readonly ICurrentTenant _currentTenant;
        private readonly ICurrentUser _currentUser;
        private readonly IDataFilter<IMultiTenant> _multiTenantDataFilter;
        private readonly ICurrentClient _currentClient;

        public HostSideDisableTenantFilterMiddleware(RequestDelegate next, ICurrentTenant currentTenant,
            ICurrentUser currentUser, IDataFilter<IMultiTenant> multiTenantDataFilter,ICurrentClient currentClient)
        {
            _next = next;
            _currentTenant = currentTenant;
            _currentUser = currentUser;
            _multiTenantDataFilter = multiTenantDataFilter;
            _currentClient = currentClient;
        }

        public async Task Invoke(HttpContext httpContext)
        {
            if (_currentUser.IsAuthenticated|| _currentClient.IsAuthenticated)
            {
                if (_currentTenant.Id == null)
                {
                    using (_multiTenantDataFilter.Disable())
                    {
                        //Next 
                        await _next(httpContext);
                    }
                }
                else
                {
                    await _next(httpContext);
                }
            }
            else
            {
                //Next 
                await _next(httpContext);
            }
        }
    }

You can write your own logic to determine when to disable this filter
And I do not think it's a common case to see tenant data in host side for a Saas platform.

@stale
Copy link

stale bot commented Jul 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants