Coder Social home page Coder Social logo

thomaschampagne / traefik-sso Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 1.47 MB

Docker image implementing a straightforward Single Sign-On authentication for your containers behind a Traefik v2 edge router

Home Page: https://hub.docker.com/r/thomaschampagne/traefik-sso

License: MIT License

Dockerfile 0.72% TypeScript 90.49% JavaScript 2.70% HTML 5.63% CSS 0.47%
sso authentication traefik docker

traefik-sso's Introduction

Version License: MIT

Docker Pulls GitHub Workflow Status

angular ng-boostrap express bcryptjs jsonwebtoken typescript rollup

code style: prettier


Traefik SSO

What'is Traefik-sso?

It's a docker image which implements a straightforward Single Sign-On authentication for containers behind a Traefik v2 edge router.

Authentication sequence to a Portainer container through Traefik v2 + Traefik-sso

Local demo

1 - Run the below docker-compose command locally

docker-compose -f ./docker-compose.yml -f ./docker-compose.local.yml up -d

See docker-compose.yml, docker-compose.local.yml & .env files

2 - When containers are up, open ${PWD}/data/db.json and add the below temporary alice user:

{
    "users": [
        {
            "username": "alice",
            "password": "$2y$10$mNJw6ojRWORz10gDaj602.8auytb58peR/hwdewqFpCershSO7DGm"
        }
    ]
}

The password has been hashed using bcrypt, value is 4lic3.

3 - Open http://iamfoo.domain.localhost in a browser (or http://iambar.domain.localhost).

4 - You should be redirected to http://sso.domain.localhost to logon on the domain domain.localhost

5 - Logon using username: alice and password: 4lic3.

6 - You should be redirected to http://iamfoo.domain.localhost (or http://iambar.domain.localhost)

7 - Logout from sso using http://sso.domain.localhost/logout. This will clear jwt token cookie on domain *.domain.localhost

Note: Environment variables used in demo are defined in .env file.

Environment variables

Name Description
DOMAIN Domain to authenticate through the sso
SECRET Secret used for JWT token signature.
TOKEN_MAX_AGE Set JWT token life time. Must match with regex: https://regex101.com/r/Q9rYJW/2
LOG_LEVEL Log level (DEBUG, INFO, WARN or ERROR). Do not use DEBUG in production.

Manage users

Users can be currently managed by editing json database file ${PWD}/data/db.json through the key users. A user-friendly UI is planned to perform this. The current workflow is temporary.

Add or edit users

To add new or update existing credentials you might use the following curl command on /hash endpoint. This api will hash the account password using bcrypt:

curl -d '{"username":"eve", "password":"3v3"}' -H "Content-Type: application/json" -X POST https://sso.domain.localhost/hash; echo

Result:

{"username":"eve","password":"$2a$10$f1sHYu64iZ0zUX6vXnqj0uLE691O0bQTV.YuHw1At2PGL8CBWk/P6"}

You need to manually add this json output in the db.json database file (users key).

Remove users

Just remove selected users entries in json array.

Configure SSO login page labels and styles

You can change every text and css styles of you sso login page by editing file ${PWD}/data/config.json.

This config.json file is following the AppConfig typescript structure

Here's the UML diagram of this structure:

UML

Note: To configure properly your styles css properties (default, small & large screens) in config.json file, you can refer to the typescript interface CSSStyleDeclaration.

Build production image

docker build -t traefik-sso:yourtag .

Local development

1 - Install npm dependencies

npm install

2 - Build local traefik-sso:dev image through compose

npm run docker:dev:build
# or
docker-compose -f ./docker-compose.yml -f ./docker-compose.dev.yml build

3 - Run local development

npm run docker:dev:up
# or
docker-compose -f ./docker-compose.yml -f ./docker-compose.dev.yml up

4 - Now follow steps from local demo section, you have same environment but in development ๐Ÿ˜Š.

traefik-sso's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar thomaschampagne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

traefik-sso's Issues

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.