Coder Social home page Coder Social logo

dotcms-oauth2-plugin's Introduction

OAuth2/OIDC SSO Plugin

This is an OSGI plugin that provides single sign-on using OAuth2/OIDC. This intended to be a drop in replacement for the standard dotcms login, both for front end users and for backend users and effectively disables the out-of-the-box login mechanism for DotCMS.


Plugin Configuration

A configuration file must be provided to configure the plugin. There is a default file located within the plugin bundle at dotcms-oauth/src/main/resources/oauth-plugin-default-configuration.properties.

If desired, a configuration file can be provided externally from the bundle in a location of your choosing (the default location is configured to be EXTERNAL_CONFIGURATION_DIRECTORY_PATH=/mnt/dotcms/plugin-configuration/ in a file named oauth-plugin-external-configuration.properties).

Furthermore, credentials and connection details that are required to connect to an Identity Provider must be provided either in a separate configuration file (oauth-provider.properties) or via AWS Parameter Store. The source of credentials and connection details is also configured in the configuration file.

Plugin Architecture

After the plugin is configured and all dependencies are injected (see PluginConfigurator.java), the control flow looks like this:

Interceptor -> UseCase -> OAuthProvider and/or DotCmsFacade and/or GroupsToRolesMapper -> UseCase -> Interceptor

Here's a UML diagram showing the same information:

UML Architecture Diagram

Interceptors

Interceptors are HTTP request filters running on DotCMS that listen for a specific URL pattern. If a URL matches, the interceptor "intercepts" the request and processes it.

com.dotcms.osgi.oauth.interceptor.BackEndLoginRequiredInterceptor

Interceptor class that "intercepts" urls that require authentication. These urls are configured in the configuration file.

  • For backend, see the property named BACK_END_LOGIN_URLS
  • For front, see the property named FRONT_END_LOGIN_URLS

When one of those URLs are intercepted, the plugin will redirect a user to an SSO provider if they are not already logged in.

com.dotcms.osgi.oauth.interceptor.OAuthCallbackInterceptor

Interceptor class that "intercepts" the configured call back url after the user is authenticated with the SSO provider.

You can change the intercepted callback url in the oauth-plugin-default-configuration.properties:

  • CALLBACK_URL=/app/oauth2/callback

How to build this example

To build the plugin, simply run: ./gradlew clean build

This will put a jar in the build/libs directory.

  • To install this bundle:

    Upload the bundle jars files using the dotCMS UI (CMS Admin->Dynamic Plugins->Upload Plugin).

  • To uninstall this bundle:

    Undeploy the bundle jars using the dotCMS UI (CMS Admin->Dynamic Plugins->Undeploy).

Using the plugin

To use this plugin, you will need to have a developer account with the authentication providers and an application registered with those providers. In each application, make sure you:

  • Authorize the application scopes required by the plugin
  • Authorize the Callback host to receive the callback.
  • Copy the application API key and API secret and set them in the config file (or in AWS Parameter Store).

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.