This repo demonstrates how you can use Ory Network or Ory Kratos with ASP.NET Core apps. This app is not for production use and serves as an example of integration.
Base on the template generated by the dotnet new mvc
command.
- dotnet sdk 7.0
- Ory cli - Used for tunneling traffic
Alternatively you can used the provided devcontainer which comes with dotnet sdk and ory-cli preinstalled.
When using your own Ory Network project, you need to add the localhost endpoint to the list of allowed urls:
ory patch project <your-project-id> \
--replace '/services/identity/config/selfservice/allowed_return_urls=["http://localhost:5286/"]'
Start an Ory Tunnel:
ory tunnel --dev --project <your-project-slug> http://localhost:5286
If you want to use the
playground project, you can call
ory tunnel
without --project
:
ory tunnel --dev http://localhost:5286
Run the app:
dotnet run ./src/ExampleApp
Open http://localhost:5286 for testing
The Dockerfile
can be found in the src
folder.
Build image:
docker build src -t dotnet-example
Run image:
docker run -it --rm -p 5286:5286 -p 4000:4000 dotnet-example
You can override the ports with APP_PORT
and ORY_TUNNEL_PORT
environment
variables. Remember that these ports must match the portforwarding. The Ory
Network project can be specified via its url using the ORY_PROJECT_URL
environment variable.
Open http://localhost:5286 for testing
Feel free to open a discussion to provide feedback or talk about ideas, or open an issue if you want to add your example to the repository or encounter a bug. You can contribute to Ory in many ways, see the Ory Contributing Guidelines for more information.