• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Review Board 1.7
    2. Version 7.x
    3. Version 6.x
    4. Version 5.0
    5. Version 4.0
    6. Version 3.0
    7. Version 2.5
    8. Version 2.0
    9. Version 1.7
    10. Version 1.6
    11. Version 1.5
    12. Version 1.0
    13. Writing Authentication Backends
  • Home
  • Users Guide
  • Getting Started
  • Introduction
  • What is Code Review?
  • General Workflow
  • Account Settings
  • Dashboard
  • Searching
  • Quick Search
  • Full-Text Search
  • Working with Review Requests
  • Creating Review Requests
  • Editing Fields
  • Uploading Diffs
  • Uploading File Attachments
  • Publishing Review Requests
  • Closing Review Requests
  • Reviewing
  • Reviewing Diffs
  • Reviewing File Attachments
  • Reviewing Images
  • Issue Tracking
  • Review Draft Banner
  • Creating and Editing Reviews
  • Publishing Reviews
  • Approving Changes (Ship It!)
  • Replying to Comments
  • Tools
  • post-review
  • Administration Guide
  • Installation
  • Installing on Linux
  • Installing on Windows
  • Installing Development Releases
  • Creating a Review Board Site
  • Upgrading
  • Upgrading Review Board
  • Upgrading Sites
  • Optimization
  • General Optimization Tips
  • Optimizing Memcached
  • Optimizing MySQL
  • Administration UI
  • Overview of the Administration UI
  • Administrator Dashboard
  • Database Management
  • Configuration
  • Site Settings
  • General Settings
  • Authentication Settings
  • E-Mail Settings
  • Diff Viewer Settings
  • Logging Settings
  • SSH Settings
  • File Storage Settings
  • Access Control
  • E-Mail
  • Default Reviewers
  • Permission Groups
  • Repositories
  • Review Groups
  • Users
  • Extensions
  • Site Maintenance
  • The rb-site Tool
  • Search Indexing
  • Advanced Management Commands
  • Web API Guide
  • Overview
  • Authenticating
  • Resource Tree
  • Resources
  • Change List Resource
  • Change Resource
  • Change Resource
  • Diff List Resource
  • Diff Resource
  • File Diff List Resource
  • File Diff Resource
  • Diff Resource
  • File Diff List Resource
  • File Diff Resource
  • File Diff Comment List Resource
  • Original File Resource
  • Patched File Resource
  • Default Reviewer List Resource
  • Default Reviewer Resource
  • Default Reviewer Resource
  • Draft File Attachment List Resource
  • Draft File Attachment Resource
  • Draft File Attachment Resource
  • Draft Screenshot List Resource
  • Draft Screenshot Resource
  • Draft Screenshot Resource
  • Extension List Resource
  • Extension Resource
  • Extension Resource
  • File Attachment Comment List Resource
  • File Attachment Comment Resource
  • File Attachment List Resource
  • File Attachment Resource
  • File Attachment Comment List Resource
  • File Attachment Resource
  • File Attachment Comment List Resource
  • File Diff Comment List Resource
  • File Diff List Resource
  • File Diff Resource
  • File Diff Comment List Resource
  • Original File Resource
  • Patched File Resource
  • File Diff Resource
  • File Diff Comment List Resource
  • Original File Resource
  • Patched File Resource
  • Hosting Service Account List Resource
  • Hosting Service Account Resource
  • Hosting Service Account Resource
  • Original File Resource
  • Patched File Resource
  • Repository Info Resource
  • Repository List Resource
  • Repository Resource
  • Repository Info Resource
  • Repository Resource
  • Repository Info Resource
  • Review Diff Comment List Resource
  • Review Diff Comment Resource
  • Review Diff Comment Resource
  • Review Draft Resource
  • Review File Attachment Comment List Resource
  • Review File Attachment Comment Resource
  • Review File Attachment Comment Resource
  • Review Group List Resource
  • Review Group Resource
  • Review Group User List Resource
  • Review Group User Resource
  • Review Group Resource
  • Review Group User List Resource
  • Review Group User Resource
  • Watched List Resource
  • Review Group User List Resource
  • Review Group User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Request List Resource
  • Review Group User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Review List Resource
  • Review Resource
  • Review Diff Comment List Resource
  • Review Diff Comment Resource
  • Review File Attachment Comment List Resource
  • Review File Attachment Comment Resource
  • Review Reply List Resource
  • Review Reply Resource
  • Review Reply Draft Resource
  • Review Screenshot Comment List Resource
  • Review Screenshot Comment Resource
  • Review Draft Resource
  • Review Reply Diff Comment List Resource
  • Review Reply Diff Comment Resource
  • Review Reply Diff Comment Resource
  • Review Reply Draft Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply List Resource
  • Review Reply Resource
  • Review Reply Diff Comment List Resource
  • Review Reply Diff Comment Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Screenshot Comment Resource
  • Review Reply Draft Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Screenshot Comment Resource
  • Review Reply Screenshot Comment Resource
  • Review Reply Resource
  • Review Reply Diff Comment List Resource
  • Review Reply Diff Comment Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Screenshot Comment Resource
  • Review Request Draft Resource
  • Draft File Attachment List Resource
  • Draft File Attachment Resource
  • Draft Screenshot List Resource
  • Draft Screenshot Resource
  • Review Request Last Update Resource
  • Review Request List Resource
  • Review Request Resource
  • Change List Resource
  • Change Resource
  • Diff List Resource
  • Diff Resource
  • File Attachment List Resource
  • File Attachment Resource
  • Review List Resource
  • Review Resource
  • Review Draft Resource
  • Review Request Draft Resource
  • Draft File Attachment List Resource
  • Draft Screenshot List Resource
  • Review Request Last Update Resource
  • Screenshot List Resource
  • Screenshot Resource
  • Review Request Resource
  • Change List Resource
  • Change Resource
  • Diff List Resource
  • Diff Resource
  • File Diff List Resource
  • File Attachment List Resource
  • File Attachment Resource
  • File Attachment Comment List Resource
  • Review List Resource
  • Review Resource
  • Review Diff Comment List Resource
  • Review File Attachment Comment List Resource
  • Review Reply List Resource
  • Review Screenshot Comment List Resource
  • Review Draft Resource
  • Review Request Draft Resource
  • Draft File Attachment List Resource
  • Draft File Attachment Resource
  • Draft Screenshot List Resource
  • Draft Screenshot Resource
  • Review Request Last Update Resource
  • Screenshot List Resource
  • Screenshot Resource
  • Screenshot Comment List Resource
  • Review Screenshot Comment List Resource
  • Review Screenshot Comment Resource
  • Review Screenshot Comment Resource
  • Review Resource
  • Review Diff Comment List Resource
  • Review Diff Comment Resource
  • Review File Attachment Comment List Resource
  • Review File Attachment Comment Resource
  • Review Reply List Resource
  • Review Reply Resource
  • Review Reply Diff Comment List Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Draft Resource
  • Review Screenshot Comment List Resource
  • Review Screenshot Comment Resource
  • Root List Resource
  • Default Reviewer List Resource
  • Default Reviewer Resource
  • Extension List Resource
  • Extension Resource
  • Hosting Service Account List Resource
  • Hosting Service Account Resource
  • Repository List Resource
  • Repository Resource
  • Repository Info Resource
  • Review Group List Resource
  • Review Group Resource
  • Review Group User List Resource
  • Review Request List Resource
  • Review Request Resource
  • Change List Resource
  • Diff List Resource
  • File Attachment List Resource
  • Review List Resource
  • Review Request Draft Resource
  • Review Request Last Update Resource
  • Screenshot List Resource
  • Search Resource
  • Server Info Resource
  • Session Resource
  • User List Resource
  • User Resource
  • Watched List Resource
  • Screenshot Comment List Resource
  • Screenshot List Resource
  • Screenshot Resource
  • Screenshot Comment List Resource
  • Screenshot Resource
  • Screenshot Comment List Resource
  • Search Resource
  • Server Info Resource
  • Session Resource
  • User List Resource
  • User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Request List Resource
  • User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Watched Review Request Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Errors
  • 100 - Does Not Exist
  • 101 - Permission Denied
  • 103 - Not Logged In
  • 104 - Login Failed
  • 105 - Invalid Form Data
  • 203 - Invalid Change Number
  • 204 - Change Number In Use
  • 205 - Missing Repository
  • 206 - Invalid Repository
  • 207 - Repository File Not Found
  • 208 - Invalid User
  • 209 - Repository Action Not Supported
  • 210 - Repository Information Error
  • 212 - Empty Changeset
  • 213 - Server Configuration Error
  • 214 - Bad Host Key
  • 215 - Unverified Host Key
  • 216 - Unverified Host Certificate
  • 217 - Missing User Key
  • 218 - Repository Authentication Error
  • 219 - Diff Empty
  • 220 - Diff Too Big
  • 221 - File Retrieval Error
  • 222 - Hosting Service Authentication Error
  • 223 - Group Already Exists
  • Glossary
  • REST API 2.0
  • Overview
  • Authenticating
  • Resources
  • Change List Resource
  • Change Resource
  • Change Resource
  • Diff List Resource
  • Diff Resource
  • File Diff List Resource
  • Diff Resource
  • File Diff List Resource
  • File Diff Resource
  • Default Reviewer List Resource
  • Default Reviewer Resource
  • Default Reviewer Resource
  • Draft File Attachment List Resource
  • Draft File Attachment Resource
  • Draft File Attachment Resource
  • Draft Screenshot List Resource
  • Draft Screenshot Resource
  • Draft Screenshot Resource
  • Extension List Resource
  • Extension Resource
  • Extension Resource
  • File Attachment Comment List Resource
  • File Attachment Comment Resource
  • File Attachment List Resource
  • File Attachment Resource
  • File Attachment Comment List Resource
  • File Attachment Resource
  • File Attachment Comment List Resource
  • File Diff Comment List Resource
  • File Diff List Resource
  • File Diff Resource
  • File Diff Comment List Resource
  • Original File Resource
  • Patched File Resource
  • File Diff Resource
  • File Diff Comment List Resource
  • Original File Resource
  • Patched File Resource
  • Hosting Service Account List Resource
  • Hosting Service Account Resource
  • Hosting Service Account Resource
  • Original File Resource
  • Patched File Resource
  • Repository Info Resource
  • Repository List Resource
  • Repository Resource
  • Repository Info Resource
  • Repository Resource
  • Repository Info Resource
  • Review Diff Comment List Resource
  • Review Diff Comment Resource
  • Review Diff Comment Resource
  • Review Draft Resource
  • Review File Attachment Comment List Resource
  • Review File Attachment Comment Resource
  • Review File Attachment Comment Resource
  • Review Group List Resource
  • Review Group Resource
  • Review Group User List Resource
  • Review Group Resource
  • Review Group User List Resource
  • Review Group User Resource
  • Review Group User List Resource
  • Review Group User Resource
  • Watched List Resource
  • Review Group User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Request List Resource
  • Review List Resource
  • Review Resource
  • Review Diff Comment List Resource
  • Review File Attachment Comment List Resource
  • Review Reply List Resource
  • Review Screenshot Comment List Resource
  • Review Draft Resource
  • Review Reply Diff Comment List Resource
  • Review Reply Diff Comment Resource
  • Review Reply Diff Comment Resource
  • Review Reply Draft Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply List Resource
  • Review Reply Resource
  • Review Reply Diff Comment List Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Draft Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Screenshot Comment Resource
  • Review Reply Screenshot Comment Resource
  • Review Reply Resource
  • Review Reply Diff Comment List Resource
  • Review Reply Diff Comment Resource
  • Review Reply File Attachment Comment List Resource
  • Review Reply File Attachment Comment Resource
  • Review Reply Screenshot Comment List Resource
  • Review Reply Screenshot Comment Resource
  • Review Request Draft Resource
  • Draft File Attachment List Resource
  • Draft File Attachment Resource
  • Draft Screenshot List Resource
  • Draft Screenshot Resource
  • Review Request Last Update Resource
  • Review Request List Resource
  • Review Request Resource
  • Change List Resource
  • Diff List Resource
  • File Attachment List Resource
  • Review List Resource
  • Review Request Draft Resource
  • Review Request Last Update Resource
  • Screenshot List Resource
  • Review Request Resource
  • Change List Resource
  • Change Resource
  • Diff List Resource
  • Diff Resource
  • File Attachment List Resource
  • File Attachment Resource
  • Review List Resource
  • Review Resource
  • Review Draft Resource
  • Review Request Draft Resource
  • Draft File Attachment List Resource
  • Draft Screenshot List Resource
  • Review Request Last Update Resource
  • Screenshot List Resource
  • Screenshot Resource
  • Review Screenshot Comment List Resource
  • Review Screenshot Comment Resource
  • Review Screenshot Comment Resource
  • Review Resource
  • Review Diff Comment List Resource
  • Review Diff Comment Resource
  • Review File Attachment Comment List Resource
  • Review File Attachment Comment Resource
  • Review Reply List Resource
  • Review Reply Resource
  • Review Reply Draft Resource
  • Review Screenshot Comment List Resource
  • Review Screenshot Comment Resource
  • Root List Resource
  • Default Reviewer List Resource
  • Default Reviewer Resource
  • Extension List Resource
  • Extension Resource
  • Hosting Service Account List Resource
  • Hosting Service Account Resource
  • Repository List Resource
  • Repository Resource
  • Review Group List Resource
  • Review Group Resource
  • Review Request List Resource
  • Review Request Resource
  • Search Resource
  • Server Info Resource
  • Session Resource
  • User List Resource
  • User Resource
  • Screenshot Comment List Resource
  • Screenshot List Resource
  • Screenshot Resource
  • Screenshot Comment List Resource
  • Screenshot Resource
  • Screenshot Comment List Resource
  • Search Resource
  • Server Info Resource
  • Session Resource
  • User List Resource
  • User Resource
  • Watched List Resource
  • User Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Request List Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Watched Review Request Resource
  • Watched List Resource
  • Watched Review Group List Resource
  • Watched Review Group Resource
  • Watched Review Request List Resource
  • Watched Review Request Resource
  • Errors
  • 100 - Does Not Exist
  • 101 - Permission Denied
  • 103 - Not Logged In
  • 104 - Login Failed
  • 105 - Invalid Form Data
  • 203 - Invalid Change Number
  • 204 - Change Number In Use
  • 205 - Missing Repository
  • 206 - Invalid Repository
  • 207 - Repository File Not Found
  • 208 - Invalid User
  • 209 - Repository Action Not Supported
  • 210 - Repository Information Error
  • 212 - Empty Changeset
  • 213 - Server Configuration Error
  • 214 - Bad Host Key
  • 215 - Unverified Host Key
  • 216 - Unverified Host Certificate
  • 217 - Missing User Key
  • 218 - Repository Authentication Error
  • 219 - Diff Empty
  • 220 - Diff Too Big
  • 221 - File Retrieval Error
  • 222 - Hosting Service Authentication Error
  • 223 - Group Already Exists
  • Glossary
  • Extending Review Board
  • Writing Review Board Extensions
  • Writing Authentication Backends
  • Writing Legacy Authentication Backends
  • Frequently Asked Questions
  • General Index
  • Release Notes
  • This documentation covers Review Board 1.7. You can select a version above or view the latest documentation.

    Writing Authentication Backends¶

    New in version 1.6: The authentication backends described here are new in Review Board 1.6. For Review Board 1.0 and 1.5, see Writing Legacy Authentication Backends.

    Overview¶

    Authentication in Review Board is handled by classes called Authentication Backends. They perform the tasks of looking up users from some database or server, authenticating against it given user credentials, and creating local representations of the users in Review Board’s database.

    Review Board provides local database, NIS, LDAP and Active Directory backends out of the box. New ones can be written to work with other types of authentication schemes.

    Authentication Classes¶

    An Authentication Backend class is a simple class inheriting from reviewboard.accounts.backends.AuthBackend. It must set the following attributes:

    • name

    And can optionally set the following attributes:

    • settings_form
    • supports_registration
    • supports_change_name
    • supports_change_email
    • supports_change_password

    It must also define the methods:

    • authenticate()
    • get_or_create_user()

    We’ll go into each function and attribute in detail.

    class reviewboard.accounts.backends.AuthBackend¶
    name¶

    This is the human-readable name of the authentication backend. This is what users will see when they go to select the authentication backend to use.

    settings_form¶

    This is an optional attribute that can be used to specify a settings form to present for any configuration needed by the backend.

    If this is not None, it must point to a djblets.siteconfig.forms.SiteSettingsForm subclass. This works like a standard Django Form, where each field name is the name of the settings key that will be automatically loaded and saved. See Settings Forms for more information.

    supports_registration¶

    A boolean that indicates whether the registration form can be used. If this is set to True, then logged out users will have the ability to register a new account.

    The registration process will create a new User in the database. Currenly, there is no support for handing off registration to the authentication backend, but it’s planned.

    supports_change_name¶

    A boolean that indicates whether a user can change his full name on the My Account page. If this is set to True, fields for the first and last name will be available and editable.

    Currently, there is no support for allowing the authentication module to handle setting the name, so it cannot update the backend server. This is planned for the future.

    supports_change_email¶

    A boolean that indicates whether a user can change his e-mail address on the My Account page. If this is set to True, a field for the e-mail address will be available and editable.

    Currently, there is no support for allowing the authentication module to handle setting the e-mail address, so it cannot update the backend server. This is planned for the future.

    supports_change_password¶

    A boolean that indicates whether a user can change his password on the My Account page. If this is set to True, a field for the password will be available and editable.

    Currently, there is no support for allowing the authentication module to handle setting the password, so it cannot update the backend server. This is planned for the future.

    authenticate(username, password)¶
    Parameters:
    • username – The user’s username.
    • password – The user’s password.
    Return type:

    The authenticated user, if authentication succeeds. On failure, None.

    Authenticates the user against a database or server.

    This is responsible for making any necessary communication with the database or server and determining the validity of the credentials passed.

    If the credentials are invalid, the function must return None, which will allow it to fall back to the next authentication backend in the chain (or fail, if this is the last authentication backend).

    If the credentials are valid, the function must return a valid User. Generally, rather than constructing one itself, it should call its own get_or_create_user() with the username.

    To help with debugging, this function should log any errors in communication using Python’s logging support.

    The function may need to strip whitespace from the username before authentication. If the server itself strips whitespace when authenticating, but this function does not, it can lead to duplicate users in the database.

    get_or_create_user(username)¶
    Parameters:username – The user’s username.
    Return type:The user, if it exists. Otherwise, None.

    Looks up or creates a User based on information from the database or server.

    This tends to follow the pattern of:

    username = username.strip()
    
    try:
        user = User.objects.get(username=username)
    except User.DoesNotExist:
        # Construct a user from the database...
        return user
    

    Like authenticate(), this will look up the user from the database or server. However, it will not verify anything other than the username. It also must make sure to strip the username.

    This function is used both when logging in and when adding a user to a review request as a reviewer. In the latter case, Review Board will look up the user using the authentication backend in order to see if the user exists and can be added.

    Settings Forms¶

    Authentication backends can provide a settings form just like the built-in backends (NIS, LDAP, etc.). The backend class just needs to set settings_form to a djblets.siteconfig.forms.SiteSettingsForm subclass (not an instance).

    This is a special sort of form where each field name is the name of the key in the settings database to store the value. The proper convention for these classes is to prefix the field name with auth_backendid_. The backendid is a short, lowercase name that represents the auth backend. For example, nis, ldap, or ad.

    Every field will be saved to the database with the exception of “blacklisted” fields. See Blacklisting Fields.

    The form can also include some metadata by way of a Meta class within the form. It can contain a title attribute, containing the title to show on the settings form, and a save_blacklist for blacklisting fields.

    The form may also provide custom load() and save() methods for handling any custom loading and saving. These must always call the parent class’s methods.

    An example class would be:

    from django import forms
    from djblets.siteconfig.forms import SiteSettingsForm
    
    
    class MySettingsForm(SiteSettingsForm):
        auth_myauth_foo = forms.CharField(
            label="Some setting",
            help_text="Some useful help text",
            required=True)
    
        auth_myauth_bar = forms.BooleanField(
            label="Another setting",
            help_text="Some more useful help text",
            required=False)
    
        class Meta:
            title = "My Auth Backend Settings"
    

    These can use any Django form fields. The actual loading and saving of settings from the database are handled under the hood.

    You can also make use of standard Django form validation to ensure that valid data was entered before save.

    Blacklisting Fields¶

    Sometimes it’s necessary to process a setting before it goes into the database or when it comes out. In this case, you don’t want the setting to be handled automatically. The field can be prevented from saving/loading by adding it to the Meta.save_blacklist attribute. This is a tuple of field names that will be ignored during save/load.

    This is usually used in conjunction with custom load() and save() methods.

    When loading a setting into a field, you should set the value in self.fields['fieldname'].initial and retrieve the value from the database when using self.siteconfig.get('settingname').

    When saving a setting from a field, you should set the value in the database using self.siteconfig.set('settingname', value) and retrieving it from the field using self.cleaned_data['fieldname'].

    For example:

    class MySettingsForm(SiteSettingsForm):
        auth_myauth_list = forms.CharField(
            label="Comma-separated list of values")
    
        def load(self):
            self.fields['auth_myauth_list'].initial = \
                ','.join(self.siteconfig.get('auth_myauth_list'))
    
            super(MySettingsForm, self).load()
    
        def save(self):
            self.siteconfig.set(
                'auth_myauth_list',
                re.split(r',\*', self.cleaned_data['auth_myauth_list']))
    
            super(MySettingsForm, self).save()
    

    Disabling Fields¶

    It can be useful to disable fields based on different conditions, such as a missing Python module. In this case, you can disable any fields in the form and provide an inline message by setting the disabled_fields and :py:`disabled_reasons` attributes during load().

    Both of these attributes are dictionaries mapping from a field name to a value. For disabled_fields, the value is a boolean indicating whether the field is disabled. For disabled_reasons, the value is a string describing why the field is disabled.

    For example:

    def load(self):
        if not get_can_enable_myauth():
            self.disabled_fields['auth_myauth_foo'] = True
            self.disabled_reasons['auth_myauth_foo'] = \
                'You must do a handstand before you can enable this ' \
                'authentication backend.'
    
        super(MySettingsForm, self).load()
    

    Accessing Settings¶

    The authentication backend can access any settings stored in the site configuration database (such as those defined in the Settings form through the djblets.siteconfig.models.SiteConfiguration API.

    Working with this is pretty simple. First, you just need to get a SiteConfiguration object:

    from djblets.siteconfig.models import SiteConfiguration
    
    
    siteconfig = SiteConfiguration.objects.get_current()
    

    You can then load and save through SiteConfiguration.set() and SiteConfiguration.get() methods. Each take a setting name and work with any native Python primitive (strings, booleans, lists, tuples, dictionaries).

    For example:

    from djblets.siteconfig.models import SiteConfiguration
    
    
    siteconfig = SiteConfiguration.objects.get_current()
    siteconfig.set('auth_myauth_foo', 'Some value')
    bar = siteconfig.get('auth_myauth_bar')
    

    Packaging¶

    Authentication backends should be packaged as a standard Python egg module. Generally, this looks something like:

    setup.py
    myauth/__init__.py
    

    The __init__.py would contain your authentication backend’s classes and logic.

    You can of course split this up into separate files (such as backends.py for the backend class and forms.py for the settings form). This is entirely up to you. However, to be a proper Python module, you must have a __init__.py, though it can be blank.

    setup.py must define an “entry point” for your module in order for Review Board to find it. This is done through the entry_points parameter passed to setup. For example:

    setup(...,
          entry_points={
              'reviewboard.auth_backends': [
                  'myauth = myauth:MyAuthBackend',
              ],
          }
    )
    

    Review Board will look in reviewboard.auth_backends for every module and attempt to load it. The module path specified must be the full Python module path for your class. The ID (myauth in the example above) can be anything, but generally should be consistent with your settings prefix for the settings form, and must not conflict with any other authentication modules.

    The authentication module can then be installed by typing (as root):

    $ python setup.py install

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • Overview
    • Authentication Classes
    • Settings Forms
      • Blacklisting Fields
      • Disabling Fields
    • Accessing Settings
    • Packaging