Skip to content

CustomUserTable

Carlo Barazzetta edited this page Jan 27, 2017 · 1 revision

How to use a Custom user table for Authentication

If you are using the DB Authenticator as explained here and here you can customize the SQL query used by the authenticator to fetch user data. This is useful in two kinds of (potentially overlapping) scenarios.

  1. You have an existing (legacy) database with its user/password table which you want to keep and use in your Kitto application.
  2. You want to select additional user data that you then use in views, etc.

Just add the ReadUserCommandText property according to the instructions in the link above (which includes a simple example).
Here is a more complex example extracted from a real-world project:

Auth: DB
  IsClearPassword: True
  ReadUserCommandText: |
    select
      WEB_USER_NAME as USER_NAME, WEB_PASSWORD as PASSWORD_HASH, WEB_ENABLED as IS_ACTIVE,
      LAST_NAME + ' ' + NAME as FULL_NAME, ID as PERSON_ID,
      coalesce((select top 1 1 from ADMIN_OPERATOR 
                where PERSON.ID = ADMIN_OPERATOR.PERSON_ID), 0) as IS_ADMIN_OPERATOR
    from PERSON
    where (WEB_USER_NAME = :P1) and (WEB_ENABLED = 1)

The additional columns other than the required USER_NAME, PASSWORD_HASH and IS_ACTIVE are custom columns used throughout the application by means of macros such as %Auth:IS_ADMIN_OPERATOR%.

Clone this wiki locally