How can I use IdentityServer4 from inside and outside a docker machine?

后端 未结 2 1057

I want to be able to authenticate against an Identity Server (STS) from outside and inside a docker machine.

I am having trouble with setting the correct authority

2条回答
  •  难免孤独
    2020-12-23 10:30

    Ensure IssuerUri is set to an explicit constant. We had similar issues with accessing Identity Server instance by the IP/hostname and resolved it this way:

    services.AddIdentityServer(x =>
    {
        x.IssuerUri = "my_auth";
    })
    

    P.S. Why don't you unify the authority URL to hostname:5000? Yes, it is possible for Client and API both call the same URL hostname:5000 if:

    • 5000 port is exposed (I see it's OK)
    • DNS is resolved inside the docker container.
    • You have access to hostname:5000 (check firewalls, network topology, etc.)

    DNS is the most tricky part. If you have any trouble with it I recommend you try reaching Identity Server by its exposed IP instead of resolving hostname.

提交回复
热议问题