Skip to content

Commit a0c34e3

Browse files
flaixgitblit
authored andcommitted
Add an Apache htpasswd user service
Add a new class, HtpasswdUserService, which performs authentication against a text file created with the Apache 'htpasswd' program. Added dependency on commons-codec:1.7
1 parent 13208e8 commit a0c34e3

File tree

15 files changed

+1056
-16
lines changed

15 files changed

+1056
-16
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<classpathentry kind="lib" path="ext/jna-3.5.0.jar" sourcepath="ext/src/jna-3.5.0.jar" />
4747
<classpathentry kind="lib" path="ext/guava-13.0.1.jar" sourcepath="ext/src/guava-13.0.1.jar" />
4848
<classpathentry kind="lib" path="ext/libpam4j-1.7.jar" sourcepath="ext/src/libpam4j-1.7.jar" />
49+
<classpathentry kind="lib" path="ext/commons-codec-1.7.jar" sourcepath="ext/src/commons-codec-1.7.jar" />
4950
<classpathentry kind="lib" path="ext/junit-4.11.jar" sourcepath="ext/src/junit-4.11.jar" />
5051
<classpathentry kind="lib" path="ext/hamcrest-core-1.3.jar" sourcepath="ext/src/hamcrest-core-1.3.jar" />
5152
<classpathentry kind="lib" path="ext/selenium-java-2.28.0.jar" sourcepath="ext/src/selenium-java-2.28.0.jar" />
@@ -58,7 +59,6 @@
5859
<classpathentry kind="lib" path="ext/httpclient-4.2.1.jar" sourcepath="ext/src/httpclient-4.2.1.jar" />
5960
<classpathentry kind="lib" path="ext/httpcore-4.2.1.jar" sourcepath="ext/src/httpcore-4.2.1.jar" />
6061
<classpathentry kind="lib" path="ext/commons-logging-1.1.1.jar" sourcepath="ext/src/commons-logging-1.1.1.jar" />
61-
<classpathentry kind="lib" path="ext/commons-codec-1.6.jar" sourcepath="ext/src/commons-codec-1.6.jar" />
6262
<classpathentry kind="lib" path="ext/commons-exec-1.1.jar" sourcepath="ext/src/commons-exec-1.1.jar" />
6363
<classpathentry kind="lib" path="ext/commons-io-2.2.jar" sourcepath="ext/src/commons-io-2.2.jar" />
6464
<classpathentry kind="output" path="bin/classes" />

NOTICE

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,12 @@ libpam4j
310310
MIT license.
311311

312312
https://github.com/kohsuke/libpam4j
313-
313+
314+
---------------------------------------------------------------------------
315+
commons-codec
316+
---------------------------------------------------------------------------
317+
commons-codec, release under the
318+
Apache License 2.0.
319+
320+
http://commons.apache.org/proper/commons-codec
321+

build.moxie

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ dependencies:
152152
- compile 'org.freemarker:freemarker:2.3.19' :war
153153
- compile 'com.github.dblock.waffle:waffle-jna:1.5' :war
154154
- compile 'org.kohsuke:libpam4j:1.7' :war
155+
- compile 'commons-codec:commons-codec:1.7' :war
155156
- test 'junit'
156157
# Dependencies for Selenium web page testing
157158
- test 'org.seleniumhq.selenium:selenium-java:${selenium.version}' @jar

gitblit.iml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,17 @@
479479
</SOURCES>
480480
</library>
481481
</orderEntry>
482+
<orderEntry type="module-library">
483+
<library name="commons-codec-1.7.jar">
484+
<CLASSES>
485+
<root url="jar://$MODULE_DIR$/ext/commons-codec-1.7.jar!/" />
486+
</CLASSES>
487+
<JAVADOC />
488+
<SOURCES>
489+
<root url="jar://$MODULE_DIR$/ext/src/commons-codec-1.7.jar!/" />
490+
</SOURCES>
491+
</library>
492+
</orderEntry>
482493
<orderEntry type="module-library" scope="TEST">
483494
<library name="junit-4.11.jar">
484495
<CLASSES>
@@ -611,17 +622,6 @@
611622
</SOURCES>
612623
</library>
613624
</orderEntry>
614-
<orderEntry type="module-library" scope="TEST">
615-
<library name="commons-codec-1.6.jar">
616-
<CLASSES>
617-
<root url="jar://$MODULE_DIR$/ext/commons-codec-1.6.jar!/" />
618-
</CLASSES>
619-
<JAVADOC />
620-
<SOURCES>
621-
<root url="jar://$MODULE_DIR$/ext/src/commons-codec-1.6.jar!/" />
622-
</SOURCES>
623-
</library>
624-
</orderEntry>
625625
<orderEntry type="module-library" scope="TEST">
626626
<library name="commons-exec-1.1.jar">
627627
<CLASSES>

releases.moxie

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ r19: {
2020
changes: ~
2121
additions:
2222
- Add setting for maximum number of days of activity to that may be requested
23-
dependencyChanges: ~
23+
- Added HtpasswdUserService to authenticate users against an htpasswd file
24+
dependencyChanges:
25+
- Added commons-codec 1.7
2426
contributors:
2527
- github/guriguri
2628
- Doug Ayers
2729
- Ori Livneh
30+
- Florian Zschocke
2831
settings:
2932
- { name: 'web.activityDurationMaximum', defaultValue: 30 }
33+
- { name: 'realm.htpasswd.userFile', defaultValue: '${baseFolder}/htpasswd' }
34+
- { name: 'realm.htpasswd.overrideLocalAuthentication', defaultValue: 'false' }
3035
}
3136

3237
#

src/main/distrib/data/gitblit.properties

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ web.projectsFile = ${baseFolder}/projects.conf
502502
# com.gitblit.SalesforceUserService
503503
# com.gitblit.WindowsUserService
504504
# com.gitblit.PAMUserService
505+
# com.gitblit.HtpasswdUserService
505506
#
506507
# Any custom user service implementation must have a public default constructor.
507508
#
@@ -1233,6 +1234,38 @@ realm.pam.backingUserService = ${baseFolder}/users.conf
12331234
# SINCE 1.3.1
12341235
realm.pam.serviceName = system-auth
12351236

1237+
# The HtpasswdUserService must be backed by another user service for standard user
1238+
# and team management and attributes. This can be one of the local Gitblit user services.
1239+
# default: users.conf
1240+
#
1241+
# RESTART REQUIRED
1242+
# BASEFOLDER
1243+
# SINCE 1.3.2
1244+
realm.htpasswd.backingUserService = ${baseFolder}/users.conf
1245+
1246+
# The Apache htpasswd file that contains the users and passwords.
1247+
# default: ${baseFolder}/htpasswd
1248+
#
1249+
# RESTART REQUIRED
1250+
# BASEFOLDER
1251+
# SINCE 1.3.2
1252+
realm.htpasswd.userfile = ${baseFolder}/htpasswd
1253+
1254+
# Determines how accounts are looked up upon login.
1255+
#
1256+
# If set to false, then authentication for local accounts is done against
1257+
# the backing user service.
1258+
# If set to true, then authentication will first be checked against the
1259+
# htpasswd store, even if the account appears as a local account in the
1260+
# backing user service. If the user is found in the htpasswd store, then
1261+
# an already existing local account will be turned into an external account.
1262+
# In this case an initial local password is never used and gets overwritten
1263+
# by the externally stored password upon login.
1264+
# default: false
1265+
#
1266+
# SINCE 1.3.2
1267+
realm.htpasswd.overrideLocalAuthentication = false
1268+
12361269
# The SalesforceUserService must be backed by another user service for standard user
12371270
# and team management.
12381271
# default: users.conf

src/main/java/com/gitblit/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ public boolean isStandard() {
480480
}
481481

482482
public static enum AccountType {
483-
LOCAL, EXTERNAL, LDAP, REDMINE, SALESFORCE, WINDOWS, PAM;
483+
LOCAL, EXTERNAL, LDAP, REDMINE, SALESFORCE, WINDOWS, PAM, HTPASSWD;
484484

485485
public boolean isLocal() {
486486
return this == LOCAL;

0 commit comments

Comments
 (0)