Custom Authentication Module

Last modified: 20 April 2023

There are two types of custom authentication modules, which can be provided by plugins: credentials authentication modules and HTTP authentication modules. The first ones are used to check the credentials user typed in login form on the login page. The second ones are used to authenticate a user by HTTP request without showing login page at all.

Credentials Authentication Module



Credentials authentication modules API is based on Sun JAAS API. To provide your own credentials authentication module you should provide a login module class which must implement the interface javax.security.auth.spi.LoginModule and register it in the jetbrains.buildServer.serverSide.auth.LoginConfiguration.

To make the authentication module active its type name can then be used during Configuring Authentication Settings.

For example:

Now we should register this module in the server. To do so, we create a login module descriptor:

Finally we should create build-server-plugin-ourUserAuth.xml and zip archive with plugin classes as it is described here and write there CustomLoginModuleDescriptor bean:

Now you should be able to change authentication scheme to your authentication module.

HTTP Authentication Module



To provide your own HTTP authentication module you should provide a class which must implement the interface jetbrains.buildServer.controllers.interceptors.auth.HttpAuthenticationScheme and register it in the jetbrains.buildServer.serverSide.auth.LoginConfiguration.

It important to check how your authentication module works with TeamCity CSRF protection and ensure that CSRF-type attack cannot be used with your authentication logic.

To make the authentication module active its type name can then be used during Configuring Authentication Settings.

For example:

Finally we should create build-server-plugin-ourUserAuth.xml and zip archive with plugin classes as it is described here and write there CustomHttpAuthenticationScheme bean:

Now you should be able to change authentication scheme to your authentication module.