-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Missing NG-TIERED OpenIddict DomainTenantResolver Example #223
Comments
@maliming in case you are busy to make full sample code, please provide some key guideline here. My specs:
ProblemWhen i access
Expected result: Here my steps on win:
Confirmed
|
hi What is the problem/error/warning you got now? |
@maliming I update my comment please review it #223 (comment) . Look like angular app can not resolve to |
hi This seems an angular issue. Can you try another URL format?
|
@maliming thanks let me try again with BTW, I prefer pattern |
Let's confirm the problem first, then we will fix it. |
@maliming http://{0}-ids.mydomain.com:44316/ to http://{0}.ids.mydomain.com:44316/ then Angular app working as expected
Relative Issue (Swagger Api App)
In 2 case above i got same overlay setting when click
When load http://tenant1.apis.mydomain.com/swagger/index.html i see xhr {
"openapi": "3.0.1",
...
"components": {
"securitySchemes": {
"oauth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "http://ids.mydomain.com:44316/connect/authorize",
"tokenUrl": "http://ids.mydomain.com:44316/connect/token",
"scopes": {
"PortX": "PortX API"
}
}
}
}
}
},
....
} @maliming Do you know the way config |
hi You can try with that: app.UseSwagger(options =>
{
options.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
{
var currentTenant = httpReq.HttpContext.RequestServices.GetRequiredService<ICurrentTenant>();
if (currentTenant.IsAvailable)
{
foreach (var securityScheme in swaggerDoc.Components.SecuritySchemes)
{
securityScheme.Value.Flows.AuthorizationCode.AuthorizationUrl = new Uri($"https://{currentTenant.Name}.localhost:44301/connect/authorize");
securityScheme.Value.Flows.AuthorizationCode.TokenUrl = new Uri($"https://{currentTenant.Name}.localhost:44301/connect/token");
}
}
});
}); |
@maliming work like a charm ^^ You are my hero.
|
Tiny issue@maliming After make more test, with above snippet i found tiny issue
Look like above middleware code act as set global state for SolutionSo i keep my snippet code here for somebody needed (Please let me know if have better solution) Edit code
app.UseSwagger(options =>
{
options.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
{
var currentTenant = httpReq.HttpContext.RequestServices.GetRequiredService<ICurrentTenant>();
var configuration = httpReq.HttpContext.RequestServices.GetRequiredService<IConfiguration>();
var authTenantResolver = configuration["App:AuthTenantResolver"]?.Trim() ?? "";
var authority = configuration["AuthServer:Authority"]?.Trim() ?? "";
var isTenantResolverPattern = authTenantResolver.Contains("{0}");
var authorityScheme = authority.Split("://")[0];
var isSubdomainTenantResolverUsed = currentTenant.IsAvailable && isTenantResolverPattern && authorityScheme != "";
var authorizationUrl = isSubdomainTenantResolverUsed
? new Uri($"{authorityScheme}://{string.Format(authTenantResolver, currentTenant.Name)}/connect/authorize")
: new Uri($"{authority}/connect/authorize");
var tokenUrl = isSubdomainTenantResolverUsed
? new Uri($"{authorityScheme}://{string.Format(authTenantResolver, currentTenant.Name)}/connect/token")
: new Uri($"{authority}/connect/token");
foreach (var securityScheme in swaggerDoc.Components.SecuritySchemes)
{
securityScheme.Value.Flows.AuthorizationCode.AuthorizationUrl = authorizationUrl;
securityScheme.Value.Flows.AuthorizationCode.TokenUrl = tokenUrl;
}
});
}); |
Can an NG-TIERED OpenIddict DomainTenantResolver example be added under https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver/OpenIddict please.
The text was updated successfully, but these errors were encountered: