mojito’s default setup comes with a form login authentication backed by the database.

Other types of authentication can be used in conjunction with the default form login. This enables to have a dual authentication scheme (potentially OAuth for regular users and form login to support tools and API integrations like the CLI.

Change or add an authentication mechanisms by updating the configuration. Eg. to add OAuth2 append it to the end,OAUTH2

You can chosse to either show the mojito’s login page or to automatically redirect to another page. Eg. to redirect to Github OAuth when the not authenticated

If the redirect is enabled, it is still possible to access mojito’s login page.

OAuth 2

mojito support OAuth 2 using standard Spring 2 / Spring Security configuration with a few additional mojito settings to customize the UI and how the user name is extracted from the user information payload.

Example with GitHub

Create a GitHub OAuth app with Authorization callback URL: http://localhost:8080/login/oauth. This URI maps to the redirect_uri in OAuth and to preEstablishedRedirectUri in Spring settings. The clientId and clientSecret are available once the app has been created.

Settings to be added, substituting the client id and secret:{ACTUAL_VALUE}{ACTUAL_VALUE}

Multiple registrations and providers

Multiple OAuth registrations and providers can be specified, see Spring security documentation for more details.

A configuration could look similar to this:[registrationId].client-id={ACTUAL_VALUE}[registrationId].client-secret={ACTUAL_VALUE}[registrationId].scope=user[registrationId].redirect-uri={baseUrl}/login/oauth2/code/{registrationId}[registrationId].authorization-grant-type=authorization_code[registrationId].client-authentication-method=post[registrationId].client-name={ACTUAL_VALUE}[providerId].token-uri=[providerId].authorization-uri=[providerId].user-info-uri=[providerId].user-name-attribute=username[registrationId].ui-label-text=My Personal OAuth


mojito can use LDAP for authentication (default uses database) by setting the following properties:${URL}${PORT}${ROOT}${USER_SEARCH_BASE}${USER_SEARCH_FILTER}${GROUP_SEARCH_BASE}${GROUP_SEARCH_FILTER}${GROUP_ROLE_ATTR}${MANAGER_DN}${MANAGER_PASSWORD}

With LDAP, the database is still used to store information about the users but the server won’t contain credentials.

When a user logs in via LDAP and there is no matching user in mojito, a new user is automatically created using the information provided by the LDAP server.

The user management is different compared to when using the database. The CLI to manage users will only change the users in mojito and won’t interact with the LDAP server. This means you can’t change a user password using this command.

As of now, there is no real need to manage users with the CLI when using LDAP as no authorization is implemented yet nor any useful information can be added. Later it could be used to change a user role, add a profile pic, etc.

Pre-authenticated with Header

If the authentication is performed by an external system, header pre-authentication can be turn on with following configuration:,DATABASE

The username is read from the x-forwarded-user http header.