authentication.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. ====================
  2. Using Authentication
  3. ====================
  4. ----------------
  5. Module: mod_auth
  6. ----------------
  7. :Author: Jan Kneschke
  8. :Date: $Date$
  9. :Revision: $Revision$
  10. :abstract:
  11. The auth module provides ...
  12. .. meta::
  13. :keywords: lighttpd, authentication
  14. .. contents:: Table of Contents
  15. Description
  16. ===========
  17. NOTE: latest documentation can be found at:
  18. https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAuth
  19. Supported Methods
  20. -----------------
  21. lighttpd supportes both authentication method described by
  22. RFC 2617:
  23. basic
  24. `````
  25. The Basic method transfers the username and the password in
  26. cleartext over the network (base64 encoded) and might result
  27. in security problems if not used in conjunction with an encrypted
  28. channel between client and server.
  29. digest
  30. ``````
  31. The Digest method only transfers a hashed value over the
  32. network which performs a lot of work to harden the
  33. authentication process in insecure networks.
  34. Backends
  35. --------
  36. Depending on the method lighttpd provides various way to store
  37. the credentials used for the authentication.
  38. for basic auth:
  39. - plain_
  40. - htpasswd_
  41. - htdigest_
  42. - ldap_
  43. for digest auth:
  44. - plain_
  45. - htdigest_
  46. plain
  47. `````
  48. A file which contains username and the cleartext password
  49. separated by a colon. Each entry is terminated by a single
  50. newline.::
  51. e.g.:
  52. agent007:secret
  53. htpasswd
  54. ````````
  55. A file which contains username and the crypt()'ed password
  56. separated by a colon. Each entry is terminated by a single
  57. newline. ::
  58. e.g.:
  59. agent007:XWY5JwrAVBXsQ
  60. You can use htpasswd from the apache distribution to manage
  61. those files. ::
  62. $ htpasswd lighttpd.user.htpasswd agent007
  63. htdigest
  64. ````````
  65. A file which contains username, realm and the md5()'ed
  66. password separated by a colon. Each entry is terminated
  67. by a single newline. ::
  68. e.g.:
  69. agent007:download area:8364d0044ef57b3defcfa141e8f77b65
  70. You can use htdigest from the apache distribution to manage
  71. those files. ::
  72. $ htdigest lighttpd.user.htdigest 'download area' agent007
  73. Using md5sum can also generate the password-hash: ::
  74. #!/bin/sh
  75. user=$1
  76. realm=$2
  77. pass=$3
  78. hash=`echo -n "$user:$realm:$pass" | md5sum | cut -b -32`
  79. echo "$user:$realm:$hash"
  80. To use it:
  81. $ htdigest.sh 'agent007' 'download area' 'secret'
  82. agent007:download area:8364d0044ef57b3defcfa141e8f77b65
  83. ldap
  84. ````
  85. the ldap backend is basically performing the following steps
  86. to authenticate a user
  87. 1. connect anonymously (at plugin init)
  88. 2. get DN for filter = username
  89. 3. auth against ldap server
  90. 4. disconnect
  91. if all 4 steps are performed without any error the user is
  92. authenticated
  93. Configuration
  94. =============
  95. ::
  96. ## type of backend
  97. # plain, htpasswd, ldap or htdigest
  98. auth.backend = "htpasswd"
  99. # filename of the password storage for
  100. # plain
  101. auth.backend.plain.userfile = "lighttpd-plain.user"
  102. ## for htpasswd
  103. auth.backend.htpasswd.userfile = "lighttpd-htpasswd.user"
  104. ## for htdigest
  105. auth.backend.htdigest.userfile = "lighttpd-htdigest.user"
  106. ## for ldap
  107. # the $ in auth.backend.ldap.filter is replaced by the
  108. # 'username' from the login dialog
  109. auth.backend.ldap.hostname = "localhost"
  110. auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
  111. auth.backend.ldap.filter = "(uid=$)"
  112. # if enabled, startTLS needs a valid (base64-encoded) CA
  113. # certificate
  114. auth.backend.ldap.starttls = "enable"
  115. auth.backend.ldap.ca-file = "/etc/CAcertificate.pem"
  116. ## restrictions
  117. # set restrictions:
  118. #
  119. # ( <left-part-of-the-url> =>
  120. # ( "method" => "digest"/"basic",
  121. # "realm" => <realm>,
  122. # "require" => "user=<username>" )
  123. # )
  124. #
  125. # <realm> is a string to display in the dialog
  126. # presented to the user and is also used for the
  127. # digest-algorithm and has to match the realm in the
  128. # htdigest file (if used)
  129. #
  130. auth.require = ( "/download/" =>
  131. (
  132. "method" => "digest",
  133. "realm" => "download archive",
  134. "require" => "user=agent007|user=agent008"
  135. ),
  136. "/server-info" =>
  137. (
  138. "method" => "digest",
  139. "realm" => "download archive",
  140. "require" => "valid-user"
  141. )
  142. )