Git Product home page Git Product logo

vaultwarden-sso's Introduction

Goal is to help testing code for the SSO PR. Based on Timshel/sso-support

⚠️ Branch will be rebased and forced-pushed when updated. ⚠️

Additionnal features

This branch now contain features not added to the SSO PR since it would slow even more it's review.

Role mapping

Allow to map roles from the Access token to users to grant access to VaultWarden admin console. Support two roles: admin or user.

This feature is controlled by the following conf:

  • SSO_ROLES_ENABLED: control if the mapping is done, default is false
  • SSO_ROLES_DEFAULT_TO_USER: do not block login in case of missing or invalid roles, default is true.
  • SSO_ROLES_TOKEN_PATH=/resource_access/${SSO_CLIENT_ID}/roles: path to read roles in the Access token

Group/Organization invitation mapping

Allow to invite user to existing Oganization if they are listed in the Access token. If activated it will check if the token contain a list of potential Orgnaization. If an Oganization with a matching name (case sensitive) is found it will the start the invitation process for this user. It will use the email associated with the Organization to send further notifications (admin side).

The flow look like this:

  • Decode the JWT Access token and check if a list of organization is present (default path is /groups).
  • Check if an Organization with a matching name exist and the user is not part of it.
  • Depending on SSO_ACCEPTALL_INVITES :
  • false - Invite the user to the Orgnization
    • The user will need to click on the link in the mail he received
    • A notification is sent tto he email associated with the Organization that a new user is ready to join
    • An admin will have to validate the user to finalize the user joining the org.
  • true - Add the user to the Organization
    • A notification is sent to the user to inform of the enrollment in the org
    • A notification is sent to the email associated with the Organization that a new user is ready to join
    • An admin will have to validate the user to confirm the user joining the org.

If email are disabled then the user will silently be enrolled and the admin will need to check the org to finish the process.

One of the bonus of invitation is that if an organization define a specific password policy then it will apply to new user when they set their new master password. If a user is part of two organizations then it will order them using the role of the user (Owner, Admin, User or Manager for now manager is last :() and return the password policy of the first one.

This feature is controlled with the following conf:

  • SSO_SCOPES: Optional scope override if additionnal scopes are needed, default is "email profile"
  • SSO_ORGANIZATIONS_INVITE: control if the mapping is done, default is false
  • SSO_ORGANIZATIONS_TOKEN_PATH: path to read groups/organization in the Access token, default is /groups

Additionnal features

This branch now contain additionnal features not added to the SSO PR since it would slow even more it's review.

Role mapping

Allow to map roles from the Access token to users to grant access to VaultWarden admin console. Support two roles: admin or user.

This feature is controlled by the following conf:

  • SSO_ROLES_ENABLED: control if the mapping is done, default is false
  • SSO_ROLES_DEFAULT_TO_USER: do not block login in case of missing or invalid roles, default is true.
  • SSO_ROLES_TOKEN_PATH=/resource_access/${SSO_CLIENT_ID}/roles: path to read roles in the Access token

Docker

Change the docker files to package both front-end from Timshel/oidc_web_builds.
By default it will use the release which only make the sso button visible.

If you want to use the version with the additional features mentionned, default redirection to /sso and fix organization invitation. You need to pass an env variable: -e SSO_FRONTEND='override' (cf start.sh).

Docker images available at:

Front-end version

By default front-end version is fixed to prevent regression (check CHANGELOG.md).
When building the docker image it can be overrided by passing the OIDC_WEB_RELEASE arg.
Ex to build with latest: --build-arg OIDC_WEB_RELEASE="https://github.com/Timshel/oidc_web_builds/releases/latest/download"

To test VaultWarden with Keycloak

Readme

Experimental version

Stop storing Master Password hash

This allow to stop storing the Master password in the server database. This is a work in progress and released for testing. Once activated newly created account will no longer store a master password hash, making reverting to a standard VaultWarden instance troublesome.

To activate

  • SSO_EXPERIMENTAL_NO_MASTER_PWD: Control the activation of the feature. Default false.

Additionnaly a new web build is available which stop sending the hash cf experimental in Timshel/oidc_web_builds You'll need to pass an env variable: -e SSO_FRONTEND='experimental' (cf start.sh).

To revert

You'll first need to run the server without the experimental front-end.
You can then go to Account settings \ Security \ Keys and trigger the Change KDF.
This endpoint is not modified and will save the new master password hash, every user will need to do this to restore a Master password in db.

DB Migration

ATM The migrations add an independant table sso_nonce and a column invited_by_email to users_organizations.

Revert to default VW

Reverting to the default VW DB state can easily be done manually (Make a backup :) :

>BEGIN;
BEGIN
>DELETE FROM __diesel_schema_migrations WHERE version in ('20230910133000', '20230914133000');
DELETE 2
>DROP TABLE sso_nonce;
DROP TABLE
>ALTER TABLE users_organizations DROP COLUMN invited_by_email;
ALTER TABLE
> COMMIT / ROLLBACK;

FROM old PR Version

⚠️ Changed the past migration creating the sso_nonce table in a recent commit.:warning:
If you already deployed the previous version you'll need to do some manual cleanup :

>BEGIN;
BEGIN
>DELETE FROM __diesel_schema_migrations WHERE version = '20230201133000';
DELETE 1
>DROP TABLE sso_nonce;
DROP TABLE
> COMMIT / ROLLBACK;

Then the new migration will play without issue.

vaultwarden-sso's People

Contributors

dani-garcia avatar blackdex avatar mprasil avatar jjlin avatar stefan0xc avatar timshel avatar njfox avatar realorangeone avatar vplme avatar tessus avatar ypid avatar janost avatar sirux88 avatar geekcornergh avatar pjsier avatar endyman avatar krankur avatar mqus avatar shauder avatar step7750 avatar publicarray avatar djbrownbear avatar manofthepeace avatar skeen avatar olivierillogika avatar blocklisted avatar zerosuxx avatar fbartels avatar itr6 avatar theycallmesteve 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.