@maliming, Excellent, thank you.
@ryancyq,
I'm not sure what you mean. Where is StaticRoleDefintion
?
I have this in StaticRoleNames.cs
:
public static class StaticRoleNames
{
public static class Host
{
public const string Admin = "Admin";
}
public static class Tenants
{
public const string Admin = "Admin";
public const string Carer = "Carer";
public const string CareSenior = "Care Senior";
public const string CareManager = "Care Manager";
}
}
and this in AppRoleConfig.cs
:
public static class AppRoleConfig
{
public static void Configure(IRoleManagementConfig roleManagementConfig)
{
//Static host roles
roleManagementConfig.StaticRoles.Add(
new StaticRoleDefinition(
StaticRoleNames.Host.Admin,
MultiTenancySides.Host,
grantAllPermissionsByDefault: true)
);
//Static tenant roles
roleManagementConfig.StaticRoles.Add(
new StaticRoleDefinition(
StaticRoleNames.Tenants.Admin,
MultiTenancySides.Tenant,
grantAllPermissionsByDefault: true)
);
roleManagementConfig.StaticRoles.Add(
new StaticRoleDefinition(
StaticRoleNames.Tenants.Carer,
MultiTenancySides.Tenant)
);
roleManagementConfig.StaticRoles.Add(
new StaticRoleDefinition(
StaticRoleNames.Tenants.CareSenior,
MultiTenancySides.Tenant)
);
roleManagementConfig.StaticRoles.Add(
new StaticRoleDefinition(
StaticRoleNames.Tenants.CareManager,
MultiTenancySides.Tenant)
);
}
}
To call RoleManager.SetGrantedPermissionsAsync(staticRole.GrantedPermissions)
as you have suggested where do I put GrantedPermissions
? Could you give me an example?
Furthermore, in the interests of DRY how do I call the same permissions from thye seed process in EntityFrameworkCore?
Thanks @ryancyq. So, if I have four tenants all with the same project manager I can link accounts in all tenants to make it easier for the project manager to traverse between tenants without having to login and out again. I think I get the drift now. I wasn't aware that accounts could be linked between tenants, I thought it was host to tenant only. This is the system which just keeps on giving!
GSuite? Is that one of the X-Men? So it's a simple way of collection users you might want to impersonate as opposed to having to go to the tenant and "Login as this user"?
For anyone interested this was the solution though I still can't see why I can't set the session on the server....
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
tenant: Tenant;
constructor(private storage: Storage) {
this.storage.get(TENANT_KEY)
.then((data) => {
this.tenant = JSON.parse(data);
});
}
intercept(req: HttpRequest<any>, next: HttpHandler) {
//Get the auth token from the service.
return Observable
.fromPromise(this.storage.get(TOKEN_KEY))
.flatMap((token) => {
// Clone the request and replace the original headers with
// cloned headers, updated with the authorization.
const authReq = req.clone({
headers: req.headers
.set('Content-Type', 'application/json')
.set('Authorization', `Bearer ${token}`)
.set('Abp.TenantId', this.tenant.tenantId.toString())
});
// send cloned request with header to the next handler.
return next.handle(authReq);
})
}
@ryancyq, thanks. here is my authorization interceptor for the angular app:
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
constructor(private storage: Storage) { }
intercept(req: HttpRequest<any>, next: HttpHandler) {
// Get the auth token from the service.
return Observable
.fromPromise(this.storage.get(TOKEN_KEY))
.flatMap((token) => {
// Clone the request and replace the original headers with
// cloned headers, updated with the authorization.
const authReq = req.clone({
headers: req.headers
.set('Content-Type', 'application/json')
.set('Authorization', `Bearer ${token}`)
});
// send cloned request with header to the next handler.
return next.handle(authReq);
})
}
Everyone keeps telling me to set Abp.TenantId in the HTTP header and then directing me to a section in the documentation which tells me how the system then gets this value. My tenant id is held in app storage, the question is how do I SET it in the above? And, on the server why doesn't this work?
using (_unitOfWorkManager.Current.SetTenantId(model.TenantId))
And, this?
AbpSession.Use(model.TenantId, null);
It seems like a lot of work, having to add to the http header, why is not possible to set it on the server?
Cheers, Bob
Are you saying that I should set some value in the http header request? Can someone show me some code on how to do that?
Nope, it's on a backburner but I do need to get back to it because I have no fallback poisition should Mongo Atlas not be available. The last time Azure reconfigured my app, changed IP's and they were not in my Mongo Atlas whitelist so I had a point of failure.
Hi Aaron, That's a good question which I can't answer without introducing you to Kendo. css is one of my pet hates but I finally got this working through the css file using your advice as a pointer:
.k-grid td {
overflow: visible;
}
Thanks for your help.
Hi Aaron, Yes, I guess you're right. But how do I fix the problem?