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

add DomainTenantResolver and with angular #3304

Closed
ChangYinShung opened this issue Mar 23, 2020 · 11 comments
Closed

add DomainTenantResolver and with angular #3304

ChangYinShung opened this issue Mar 23, 2020 · 11 comments
Assignees
Milestone

Comments

@ChangYinShung
Copy link
Contributor

hi
when i add DomainTenantResolver at C# like this:

options.AddDomainTenantResolver("{0}.mydomain.com");

i deploy to iis and create a tenant call testTenant

in angular environment.ts file i set apis url as blank

  oAuthConfig: {
    issuer: 'http://mydomain.com',
    clientId: 'BookStore_App',
    dummyClientSecret: '1q2w3e*',
    scope: 'BookStore',
    showDebugInformation: true,
    oidc: false,
    requireHttps: false
  },
  apis: {
    default: {
      url: ''
    }
  }

I open browser http://testTenant.mydomain.com and click login button
create following http request :

the problem is user login in at :http://testTenant.mydomain.com

login admin account, but ConfigState's CurentUser's tenantId is still null
or this issue is cause by angular-oauth2-oidc?

@hikalkan hikalkan added this to the 2.4 milestone Mar 24, 2020
@ismcagdas
Copy link
Member

@ChangYinShung This might be related to angular-oauth2-oidc but I'm not %100 sure. Could you try to change your config like this;

oAuthConfig: {
    issuer: '',
    clientId: 'BookStore_App',
    dummyClientSecret: '1q2w3e*',
    scope: 'BookStore',
    showDebugInformation: true,
    oidc: false,
    requireHttps: false,
    skipIssuerCheck: true
  }

@ChangYinShung
Copy link
Contributor Author

@ismcagdas
When I login as Host : http://mydomain.com/
the request become
http://mydomain.com/.well-known/openid-configuration
http://mydomain.com/.well-known/openid-configuration/jwt
http://mydomain.com/connect/token
http://mydomain.com/api/abp/application-configuration

And CurrentUser Data

{
     isAuthenticated:true,
     id: "59e5689b-a0a3-3633-8739-39f33b93bd77",
     tenantId:null,
     userName:"admin"
    }

When I login as tenant : http://testTenant.mydomain.com/
the request become
http://testTenant.mydomain.com/.well-known/openid-configuration
http://testTenant.mydomain.com/.well-known/openid-configuration/jwt
http://testTenant.mydomain.com/connect/token
http://testTenant.mydomain.com/api/abp/application-configuration

In Store data

{
  ConfigState:{
   currentUser:{
     isAuthenticated:false,
     id: null,
     tenantId:null,
     userName:null
    },
    currentTenant:{id:'9dfd612c-b460-1922-9961-39f378e8cf90',name:'testTenant'}
  }
}

Host user login is work ,but testTenant not work ?

@ismcagdas
Copy link
Member

Is it possible for you to share a test url and test credentails with us for testing tenant login ? If that is private, you can send it to info@abp.io.

@ChangYinShung
Copy link
Contributor Author

ChangYinShung commented Mar 27, 2020

hi @ismcagdas , I upload my test project on github and write some test environment and description on readme.md

https://github.com/ChangYinShung/abpDomainTenant

@ChangYinShung
Copy link
Contributor Author

The iis log print when i login to http://tenant1.furthersoftware.com.tw :

2020-03-30 21:44:43.068 +08:00 [INF] {"ClientId":"DomainTenantTest_App","ClientName":"DomainTenantTest_App","RedirectUri":null,"Endpoint":"Token","SubjectId":"1b2aa644-2bad-8404-de1e-39f42ded6b64","Scopes":"DomainTenantTest","GrantType":"password","Tokens":[{"TokenType":"access_token","TokenValue":"****IZ8g","$type":"Token"}],"Category":"Token","Name":"Token Issued Success","EventType":"Success","Id":2000,"Message":null,"ActivityId":"800002b5-0002-f900-b63f-84710c7967bb","TimeStamp":"2020-03-30T13:44:43.0000000Z","ProcessId":5096,"LocalIpAddress":"192.168.1.6:80","RemoteIpAddress":"106.104.7.23","$type":"TokenIssuedSuccessEvent"}
2020-03-30 21:44:43.080 +08:00 [INF] Request finished in 650.5209ms 200 application/json; charset=UTF-8
2020-03-30 21:44:43.086 +08:00 [INF] Request starting HTTP/1.1 GET http://tenant.demo1.furthersoftware.com.tw/api/abp/application-configuration  
2020-03-30 21:44:43.279 +08:00 [INF] Request starting HTTP/1.1 GET http://demo1.furthersoftware.com.tw/.well-known/openid-configuration  
2020-03-30 21:44:43.285 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.290 +08:00 [INF] Executed DbCommand (4ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.296 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.299 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.302 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.305 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.310 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.313 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.317 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.320 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.324 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.326 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.330 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.333 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.337 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.341 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.345 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.348 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.353 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.356 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.360 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'SettingManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.363 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__name_0='?' (Size = 128), @__providerName_1='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [a].[Id], [a].[Name], [a].[ProviderKey], [a].[ProviderName], [a].[Value]
FROM [AbpSettings] AS [a]
WHERE (([a].[Name] = @__name_0) AND ([a].[ProviderName] = @__providerName_1)) AND [a].[ProviderKey] IS NULL
2020-03-30 21:44:43.366 +08:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryEndpoint for /.well-known/openid-configuration
2020-03-30 21:44:43.368 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'IdentityServerDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.429 +08:00 [INF] Executed DbCommand (60ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean)], CommandType='"Text"', CommandTimeout='30']
SELECT [i].[Id], [i].[ConcurrencyStamp], [i].[CreationTime], [i].[CreatorId], [i].[DeleterId], [i].[DeletionTime], [i].[Description], [i].[DisplayName], [i].[Emphasize], [i].[Enabled], [i].[ExtraProperties], [i].[IsDeleted], [i].[LastModificationTime], [i].[LastModifierId], [i].[Name], [i].[Properties], [i].[Required], [i].[ShowInDiscoveryDocument], [i0].[IdentityResourceId], [i0].[Type]
FROM [IdentityServerIdentityResources] AS [i]
LEFT JOIN [IdentityServerIdentityClaims] AS [i0] ON [i].[Id] = [i0].[IdentityResourceId]
WHERE (@__ef_filter__p_0 = CAST(1 AS bit)) OR ([i].[IsDeleted] <> CAST(1 AS bit))
ORDER BY [i].[Id], [i0].[IdentityResourceId], [i0].[Type]
2020-03-30 21:44:43.434 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'IdentityServerDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.437 +08:00 [INF] Executed DbCommand (2ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean)], CommandType='"Text"', CommandTimeout='30']
SELECT [i].[Id], [i].[ConcurrencyStamp], [i].[CreationTime], [i].[CreatorId], [i].[DeleterId], [i].[DeletionTime], [i].[Description], [i].[DisplayName], [i].[Enabled], [i].[ExtraProperties], [i].[IsDeleted], [i].[LastModificationTime], [i].[LastModifierId], [i].[Name], [i].[Properties], [i0].[ApiResourceId], [i0].[Type], [i0].[Value], [i0].[Description], [i0].[Expiration], [i1].[ApiResourceId], [i1].[Type], [t].[ApiResourceId], [t].[Name], [t].[Description], [t].[DisplayName], [t].[Emphasize], [t].[Required], [t].[ShowInDiscoveryDocument], [t].[ApiResourceId0], [t].[Name0], [t].[Type]
FROM [IdentityServerApiResources] AS [i]
LEFT JOIN [IdentityServerApiSecrets] AS [i0] ON [i].[Id] = [i0].[ApiResourceId]
LEFT JOIN [IdentityServerApiClaims] AS [i1] ON [i].[Id] = [i1].[ApiResourceId]
LEFT JOIN (
    SELECT [i2].[ApiResourceId], [i2].[Name], [i2].[Description], [i2].[DisplayName], [i2].[Emphasize], [i2].[Required], [i2].[ShowInDiscoveryDocument], [i3].[ApiResourceId] AS [ApiResourceId0], [i3].[Name] AS [Name0], [i3].[Type]
    FROM [IdentityServerApiScopes] AS [i2]
    LEFT JOIN [IdentityServerApiScopeClaims] AS [i3] ON ([i2].[ApiResourceId] = [i3].[ApiResourceId]) AND ([i2].[Name] = [i3].[Name])
) AS [t] ON [i].[Id] = [t].[ApiResourceId]
WHERE (@__ef_filter__p_0 = CAST(1 AS bit)) OR ([i].[IsDeleted] <> CAST(1 AS bit))
ORDER BY [i].[Id], [i0].[ApiResourceId], [i0].[Type], [i0].[Value], [i1].[ApiResourceId], [i1].[Type], [t].[ApiResourceId], [t].[Name], [t].[ApiResourceId0], [t].[Name0], [t].[Type]
2020-03-30 21:44:43.441 +08:00 [INF] Request finished in 161.5684ms 200 application/json; charset=UTF-8
2020-03-30 21:44:43.536 +08:00 [INF] Request starting HTTP/1.1 GET http://demo1.furthersoftware.com.tw/.well-known/openid-configuration/jwks  
2020-03-30 21:44:43.541 +08:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryKeyEndpoint for /.well-known/openid-configuration/jwks
2020-03-30 21:44:43.541 +08:00 [INF] Request finished in 5.4568ms 200 application/jwk-set+json; charset=UTF-8
2020-03-30 21:44:43.626 +08:00 [INF] Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10205: Issuer validation failed. Issuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' or validationParameters.ValidIssuers: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
   at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateIssuer(String issuer, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
2020-03-30 21:44:43.628 +08:00 [INF] BearerIdentityServerAuthenticationJwt was not authenticated. Failure message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' or validationParameters.ValidIssuers: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
2020-03-30 21:44:43.630 +08:00 [INF] Bearer was not authenticated. Failure message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' or validationParameters.ValidIssuers: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
2020-03-30 21:44:43.632 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'TenantManagementDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:43.635 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__name_0='?' (Size = 64)], CommandType='"Text"', CommandTimeout='30']
SELECT [t].[Id], [t].[ConcurrencyStamp], [t].[CreationTime], [t].[CreatorId], [t].[DeleterId], [t].[DeletionTime], [t].[ExtraProperties], [t].[IsDeleted], [t].[LastModificationTime], [t].[LastModifierId], [t].[Name], [a0].[TenantId], [a0].[Name], [a0].[Value]
FROM (
    SELECT TOP(1) [a].[Id], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[CreatorId], [a].[DeleterId], [a].[DeletionTime], [a].[ExtraProperties], [a].[IsDeleted], [a].[LastModificationTime], [a].[LastModifierId], [a].[Name]
    FROM [AbpTenants] AS [a]
    WHERE ((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([a].[IsDeleted] <> CAST(1 AS bit))) AND ([a].[Name] = @__name_0)
) AS [t]
LEFT JOIN [AbpTenantConnectionStrings] AS [a0] ON [t].[Id] = [a0].[TenantId]
ORDER BY [t].[Id], [a0].[TenantId], [a0].[Name]
2020-03-30 21:44:43.638 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2020-03-30 21:44:43.639 +08:00 [INF] Route matched with {action = "Get", controller = "AbpApplicationConfiguration", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync() on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
2020-03-30 21:44:43.641 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.641 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.641 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.642 +08:00 [INF] Authorization failed.
2020-03-30 21:44:43.645 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
2020-03-30 21:44:43.657 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 18.2958ms
2020-03-30 21:44:43.657 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2020-03-30 21:44:43.657 +08:00 [INF] Request finished in 571.9887ms 200 application/json; charset=utf-8
2020-03-30 21:44:47.688 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'BackgroundJobsDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:47.691 +08:00 [INF] Executed DbCommand (2ms) [Parameters=[@__p_1='?' (DbType = Int32), @__now_0='?' (DbType = DateTime2)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(@__p_1) [a].[Id], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[ExtraProperties], [a].[IsAbandoned], [a].[JobArgs], [a].[JobName], [a].[LastTryTime], [a].[NextTryTime], [a].[Priority], [a].[TryCount]
FROM [AbpBackgroundJobs] AS [a]
WHERE ([a].[IsAbandoned] <> CAST(1 AS bit)) AND ([a].[NextTryTime] <= @__now_0)
ORDER BY [a].[Priority] DESC, [a].[TryCount], [a].[NextTryTime]
2020-03-30 21:44:52.694 +08:00 [INF] Entity Framework Core 3.1.0 initialized 'BackgroundJobsDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
2020-03-30 21:44:52.696 +08:00 [INF] Executed DbCommand (1ms) [Parameters=[@__p_1='?' (DbType = Int32), @__now_0='?' (DbType = DateTime2)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(@__p_1) [a].[Id], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[ExtraProperties], [a].[IsAbandoned], [a].[JobArgs], [a].[JobName], [a].[LastTryTime], [a].[NextTryTime], [a].[Priority], [a].[TryCount]
FROM [AbpBackgroundJobs] AS [a]
WHERE ([a].[IsAbandoned] <> CAST(1 AS bit)) AND ([a].[NextTryTime] <= @__now_0)
ORDER BY [a].[Priority] DESC, [a].[TryCount], [a].[NextTryTime]

The error seem happen at Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10205: Issuer validation failed. Issuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' or validationParameters.ValidIssuers: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.

but http response 200 ,but actually user login fail.

@ChangYinShung
Copy link
Contributor Author

So I skip the issuer check & audience check

            context.Services.AddAuthentication()
                .AddIdentityServerAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme, options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = false;
                    //options.ApiName = "DomainTenantTest";
                    //options.JwtBackChannelHandler = new HttpClientHandler()
                    //{
                    //    ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
                    //};
                    options.TokenValidationParameters.ValidateAudience = false;
                    options.TokenValidationParameters.ValidateIssuer = false;
                },option=> { });

And it work ,but i dont know why IDX10205: Issuer validation failed happen?

And i find some reference
https://stackoverflow.com/questions/53515992/turn-off-issuer-validation-or-modify-valid-issuers-in-identityserver4

here is my branch: https://github.com/ChangYinShung/abpDomainTenant/tree/skipIssuer

@mehmet-erim mehmet-erim modified the milestones: 2.4, 2.5 Apr 1, 2020
@thk-liu
Copy link

thk-liu commented Apr 4, 2020

So I skip the issuer check & audience check

            context.Services.AddAuthentication()
                .AddIdentityServerAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme, options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = false;
                    //options.ApiName = "DomainTenantTest";
                    //options.JwtBackChannelHandler = new HttpClientHandler()
                    //{
                    //    ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
                    //};
                    options.TokenValidationParameters.ValidateAudience = false;
                    options.TokenValidationParameters.ValidateIssuer = false;
                },option=> { });

And it work ,but i dont know why IDX10205: Issuer validation failed happen?

And i find some reference
https://stackoverflow.com/questions/53515992/turn-off-issuer-validation-or-modify-valid-issuers-in-identityserver4

here is my branch: https://github.com/ChangYinShung/abpDomainTenant/tree/skipIssuer

hi, I have the same problem under the secondary domain. I refer to the link https://stackoverflow.com/questions/50119467/azure-multi-tenant-asp-net-core-application-with-bearer-authorization .
Final executable code:

            //see https://github.com/abpframework/abp/issues/3304
            // see: https://stackoverflow.com/questions/53515992/turn-off-issuer-validation-or-modify-valid-issuers-in-identityserver4
            context.Services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
                .AddJwtBearer(options =>
            {
                options.Authority = configuration["AuthServer:Authority"];
                options.Audience = configuration["AuthServer:ApiName"];
                options.RequireHttpsMetadata = false; // or false if you dont have https
                options.TokenValidationParameters.ValidateIssuer = false;
            });

it`s works.no other problems found

@ismcagdas
Copy link
Member

Thank you for sharing your solution. At the moment, I don't know how to fix the problem when ValidateIssuer is true.

@ebicoglu ebicoglu modified the milestones: 2.5, 2.6 Apr 10, 2020
@mehmet-erim mehmet-erim assigned ismcagdas and unassigned mehmet-erim Apr 14, 2020
@hikalkan hikalkan modified the milestones: 2.6, 2.7 Apr 19, 2020
@hikalkan hikalkan modified the milestones: 2.7, 2.8 May 7, 2020
@ismcagdas ismcagdas modified the milestones: 2.8, 2.9 May 20, 2020
@brainedcode
Copy link

Hi Guys,

You all guys are doing wonderful job. Thank you so much for your efforts and wonderful thought.

I am trying to test multi tenant (subdomain) on localhost using angular platform with following the below steps:
Step 1. Added "options.AddDomainTenantResolver("{0}.mydomain.com") and added corsorigin too.
Step 2. Added test1.mydomain.com, test2.mydomain.com in hosts file (as I am using windows OS).
Step 3. Run the asp.net project on localhost.
Step 4: Build the angular project and then hosted on IIS with bindings *.mydomain.com and mydomain.com
Step 5: Logged in as admin in host (angular) http://mydomain.com and added two test tenants (test1, test2).
Step 6: Logged out and tried with subdomain http://test1.mydomain.com (angular), it does not auto bind tenant. -- ISSUE 1
Step 7: Even after set tenant from tenant switch box and logged in, it still logged into as host app with subdomain url. - ISSUE 2

What else should I need to do to consider subdomain from URL in angular project?

@maliming
Copy link
Member

@brainedcode #4817

@maliming
Copy link
Member

maliming commented Aug 5, 2020

hi @ChangYinShung

Maybe you can customize IssuerValidator of TokenValidationParameters.

IssuerValidator = (issuer, token, parameters) =>
{
	if (expr)
	{
		
	}
	return issuer;
}

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

No branches or pull requests

8 participants