This repository contains a example to show the use of oauth2-proxy with NestJS API, NextJS frontend and Keycloak for authentication.
The repository includes a Nix Flake for easy setup. Be sure to enable flakes in your Nix installation.
If you do not have Nix installed, run the following command for the complete setup using the Determinate Nix Installer:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
direnv configuration is also included in the repository allowing automatic setup of environment whenever a shell is started in the project's directory.
-
direnv
can be installed using brew on MacOS. For other systems use the relevant package.:brew install direnv
-
Make sure
direnv
is hooked into your shell. For zsh add the following line to~/.zshrc
:eval "$(direnv hook zsh)"
-
On VSCode, direnv VSCode Extension is recommended. It loads the environment at the workspace root level. Allowing VSCode features like the integrated terminal to have access to the shell environment instantaneously.
Activating the shell environment for the first time will take some time. Use either one of the following methods to get started.
For security reasons direnv
doesn't load the shell environment automatically. Clone this repository and run the following command to allow direnv
to trust the repository:
direnv allow .
This needs to be done only once. Now whenever a shell is opened in this repository direnv
will automatically start the shell environment.
Clone this repository and whenever you need to start developing run the following command to start the nix dev-shell:
nix develop --impure .
Once in the development environment run the following command to import the expected keycloak realm:
keycloak-import
- Start the required processes with process-compose:
devenv up
- Once all the processes are up and running, access the example at localhost:4180