Giter Site home page Giter Site logo

traefik_cloudflare_oauth_n8n's Introduction

Original code

cfrigi83/traefik-examples/example_oauth

Traefik with OAuth of Google with n8n server

The goal of this example is to make more secure access to traefik services with a login on the Google account (and maybe with a 2FA). This approach is recommended to the services that you want to make accessible on the internet, but there is no access control (login).

  1. client launches the site {SUBDOMAIN}.{DOMAIN}.com
  2. traefik redirect the client to Google for the login
  3. after successful login on Google traefik check if the user access is allowed.
  4. the client sees the website.

This example is not like an SSO (Single Sign-On), it put a security step before the service is launched.

Getting Started

Prerequisites

  1. Configuration DNS to on cloudflare and add A record to IP of server.
  2. One or multiple Google account.
  3. Install the docker and docker-compose using bash install_docker.sh

Steps

  1. Create on console.developers.google.com/apis/credentials a new project.

  2. In this project create a new ID Client OAuth2.

  3. Add every container domain where you want to use OAuth sub.example.org/_oauth. Add /_oauth at the end of every domain. You can put a domain that is not reachable from the internet.

  4. Put the client ID, client secret in the .env file for the variables GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.

  5. Generate a secret with the command and put the result in the .env file for the variable OAUTH_SECRET.

openssl rand -hex 16
  1. In the variable WHITELIST in the sample_env file you can define the allowed email addresses. If you have a G-Suite account you can make a domain whitelist with the variable DOMAIN, but you have to delete the variable WHITELIST.

More config traefik-forward-auth#configuration

  1. Add these labels to the docker containers you want to protect (docker-compose syntax). Please make attention to the routers and the middlewares name.
# Oauth for whoami
- "traefik.http.routers.whoami.middlewares=whoamisecure"
- "traefik.http.middlewares.whoamisecure.forwardauth.address=http://oauth:4181"
- "traefik.http.middlewares.whoamisecure.forwardauth.authResponseHeaders=X-Forwarded-User"
- "traefik.http.middlewares.whoamisecure.forwardauth.authResponseHeaders=X-Auth-User, X-Secret"
- "traefik.http.middlewares.whoamisecure.forwardauth.trustForwardHeader=true"
  1. Set up all required variable from on sample_env and Rename .sample_env to .env
  2. Make volume
docker volume create --name postgresql
docker volume create --name n8n
docker volume create --name postgresql_data
  1. start the container with the command.
docker-compose up -d 
  1. Test the connection with the site {SUBDOMAIN}.{DOMAIN}.com, now a redirect will happen first.

traefik_cloudflare_oauth_n8n's People

Contributors

bkrmdahal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.