Network
Suppose you have two physical machines: C1 and C2. Each machine is a docker host.
C1 starts the Auth container.
C2 launches the WebApi container.
When you expose port 5000 in the Auth docker file, the address C1:5000 must be accessible from C2 and from the WebApi container itself. You may prefer DNS IP addresses, it doesn't matter. In addition, you should be able to make a successful GET request to http://C1:5000/.well-known/openid-configuration .
There are many network problems you may encounter in order to achieve this. For example: What would prevent code running in the Docker container from connecting to the database on a separate server?
Issuer Validation
Issuer authorization error
Your client URL is different from the Auth host name. By default, the credential URL should be equal to the value of the issuer property (this property is in response to Autodiscover Identity Server).
issuer The value of the property depends on your client web request:
GET http://127.0.0.1:6000/.well-known/openid-configuration -> "issuer": "http://127.0.0.1:6000" GET http://localhost:6000/.well-known/openid-configuration -> "issuer": "localhost:6000"
Try setting the IssuerUri constant for the dev environment:
services.AddIdentityServer(x => { x.IssuerUri = "foo"; })
to achieve a constant issuer value. This allows you to call Identity Server at any valid URL (using IP, computer name, or DNS):
GET http://anything/.well-known/openid-configuration -> "issuer": "foo"
DiscoveryClient also checks the issuer value. This is a simple equality comparison :
public bool ValidateIssuerName(string issuer, string authority) { return string.Equals(issuer, authority, StringComparison.Ordinal); }
You can disable it:
DiscoveryClient.Policy.ValidateIssuerName = false;
FYI, IssuerUri setup is not recommended for the work environment:
IssuerUri Indicate the name of the issuer that appears in the opening document and the issued JWT tokens. It is recommended that you do not set this property, which indicates the name of the issuer on behalf of the host used by clients.