Skip to content

An example to show the use of oauth2-proxy with NestJS API, NextJS frontend and Keycloak for authentication.

Notifications You must be signed in to change notification settings

mirza-src/oauth2-proxy-example

Repository files navigation

NextJS + NextJS + Keycloak with oauth2-proxy

This repository contains a example to show the use of oauth2-proxy with NestJS API, NextJS frontend and Keycloak for authentication.

Setup

Prerequisites

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

Recommendations

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.

Getting Started

Activating the shell environment for the first time will take some time. Use either one of the following methods to get started.

Activating Shell Environment

With direnv (recommended)

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.

Without direnv:

Clone this repository and whenever you need to start developing run the following command to start the nix dev-shell:

nix develop --impure .

Starting example

Once in the development environment run the following command to import the expected keycloak realm:

keycloak-import
devenv up
  • Once all the processes are up and running, access the example at localhost:4180

About

An example to show the use of oauth2-proxy with NestJS API, NextJS frontend and Keycloak for authentication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published