gitblit/gitblit — pull request #29 by mavimo (2012-08-16 14:58:06+00:00)
Title: Added SqlUserService

This is the first implementation of user login based on external SQL source (I test it with MySQL 5.5).

### Disclaimer:
I'm not a Java developer, and I write this code for only internal usage, so I think is just a base to extend.

### Note:
Only _authentication_ by username/password method is implemented and work fine (need more test, but login work fine with/without password hashing, salt, ..).

### How it work
Into *.properties file there are some settings to bind gitblit to SQL database. Administrator must set JDBC driver (require to put the jar into /ext folder) and setup connecction data (url / username / password).
Admin must also set query to return name, password and mail. I expose the query to admin to make this system really flexible (eg using join, aliasis, ...).

All application (MUST) store password encrypted, so there are settings for salt (before/post password) and hash algorithm.

This is my example configuartion:

```ini
# Login system
realm.userService = com.gitblit.SqlUserService

# Backing user service
realm.sql.backingUserService = users.conf

# JDBC driver to use in server connection
realm.sql.driver = com.mysql.jdbc.Driver

# JDBC server connecton url
realm.sql.url = jdbc:mysql://localhost:3306/test_gitblit

# DB Server login credentials
realm.sql.username = test
realm.sql.password = test

# Query to select user
realm.sql.selectUser = SELECT username AS name, password, mail FROM users WHERE username = ? AND password = ?

# SALT
realm.sql.saltPre = XXXXXXXXXXXXXXXXXXXXX-

# Password encrypting algorithm
realm.sql.passwordStorage = SHA-256
```

### TODO:
* add authenticate by cookies (external application maybee store sessions on DB, so can be possible have automatically authentication on subdomain).
* Add support for TeamMembership (on user load)
* Add support for method support**Properties**Change