2
0
Commit Graph

58 Commits

Author SHA1 Message Date
Lauris BH
801cb3b447 Add restricted user filter to LDAP authentication (#10600)
* Add restricted user filter to LDAP authentification

* Fix unit test cases
2020-03-05 08:30:33 +02:00
zeripath
3c83e7d5b6 Add option to prevent LDAP from deactivating everything on empty search (#9879)
* Add option to prevent LDAP from deactivating everything on empty search

* Update options/locale/locale_en-US.ini

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-20 11:47:39 +08:00
David Svantesson
989a6a09cf Abort syncrhonization from LDAP source if there is some error. (#7960)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
2019-08-24 21:53:37 +03:00
ngourdon
6610479c6a Set user search base field optional in DLDAP edit page (#6779) 2019-04-28 09:53:55 -04:00
zeripath
74d4686043 Better logging (#6038) (#6095)
* Panic don't fatal on create new logger

Fixes #5854

Signed-off-by: Andrew Thornton <art27@cantab.net>

* partial broken

* Update the logging infrastrcture

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Reset the skip levels for Fatal and Error

Signed-off-by: Andrew Thornton <art27@cantab.net>

* broken ncsa

* More log.Error fixes

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Remove nal

* set log-levels to lowercase

* Make console_test test all levels

* switch to lowercased levels

* OK now working

* Fix vetting issues

* Fix lint

* Fix tests

* change default logging to match current gitea

* Improve log testing

Signed-off-by: Andrew Thornton <art27@cantab.net>

* reset error skip levels to 0

* Update documentation and access logger configuration

* Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE

* Fix broken level caching

* Refactor the router log

* Add Router logger

* Add colorizing options

* Adjust router colors

* Only create logger if they will be used

* update app.ini.sample

* rename Attribute ColorAttribute

* Change from white to green for function

* Set fatal/error levels

* Restore initial trace logger

* Fix Trace arguments in modules/auth/auth.go

* Properly handle XORMLogger

* Improve admin/config page

* fix fmt

* Add auto-compression of old logs

* Update error log levels

* Remove the unnecessary skip argument from Error, Fatal and Critical

* Add stacktrace support

* Fix tests

* Remove x/sync from vendors?

* Add stderr option to console logger

* Use filepath.ToSlash to protect against Windows in tests

* Remove prefixed underscores from names in colors.go

* Remove not implemented database logger

This was removed from Gogs on 4 Mar 2016 but left in the configuration
since then.

* Ensure that log paths are relative to ROOT_PATH

* use path.Join

* rename jsonConfig to logConfig

* Rename "config" to "jsonConfig" to make it clearer

* Requested changes

* Requested changes: XormLogger

* Try to color the windows terminal

If successful default to colorizing the console logs

* fixup

* Colorize initially too

* update vendor

* Colorize logs on default and remove if this is not a colorizing logger

* Fix documentation

* fix test

* Use go-isatty to detect if on windows we are on msys or cygwin

* Fix spelling mistake

* Add missing vendors

* More changes

* Rationalise the ANSI writer protection

* Adjust colors on advice from @0x5c

* Make Flags a comma separated list

* Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING

* Ensure matching is done on the non-colored message - to simpify EXPRESSION
2019-04-02 08:48:31 +01:00
zeripath
a078916b1b Move to ldap.v3 to fix #5928 (#6105)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2019-02-18 12:34:37 +00:00
Lauris BH
3dcc40f3a9 Request for public keys only if LDAP attribute is set (#5816)
* Update go-ldap dependency

* Request for public keys only if attribute is set
2019-01-24 01:25:33 +02:00
Harshit Bansal
dcfd4fe1e6 ldap: Adjust log settings when a user is not found. (#5771)
Fixes: #3849.
2019-01-19 14:57:27 -05:00
zeripath
08f6541e4c Synchronize SSH keys on login with LDAP + Fix SQLite deadlock on ldap ssh key deletion (#5557)
* Synchronize SSH keys on login with LDAP

* BUG: Fix hang on sqlite during LDAP key deletion
2018-12-27 12:28:48 -05:00
Tony Homrich
b57767cf01 LDAP via simple auth separate bind user and search base (#5055) 2018-12-27 11:51:19 -05:00
Magnus Lindvall
833ee54635 LDAP Public SSH Keys synchronization (#1844)
* Add LDAP Key Synchronization feature

Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>

* Add migration: add login source id column for public_key table

* Only update keys if needed

* Add function to only list pubkey synchronized from ldap

* Only list pub ssh keys synchronized from ldap. Do not sort strings as ExistsInSlice does it.

* Only get keys belonging to current login source id

* Set default login source id to 0

* Some minor cleanup. Add integration tests (updete dep testify)
2018-05-24 07:59:02 +03:00
Lauris BH
017eb180ba Add option to use paged LDAP search when synchronizing users (#3895) 2018-05-05 17:30:47 +03:00
Sandro Santilli
3b70e49de5 Gogs -> Gitea (#2909)
rename label
2017-11-14 08:55:57 +08:00
Jochen Rill
d8f1d5cfc1 Correct ldap username validation. (#2880)
PR #342 was only partially applied. Spaces should not be at the start
and end of a username but they can be inside.
2017-11-13 11:32:16 +02:00
Lauris BH
a6a6c63ed6 LDAP user synchronization (#1478) 2017-05-10 15:10:18 +02:00
Denis Denisov
8e8127a403 Correction LDAP validation (#342)
* Correction LDAP username validation

As https://msdn.microsoft.com/en-us/library/aa366101(v=vs.85).aspx describe spaces should not be in start or at the end of username but they can be inside the username. So please check my solution for it.

* Check for zero length passwords in LDAP module.

According to https://tools.ietf.org/search/rfc4513#section-5.1.2 LDAP client should always check before bind whether a password is an empty value. There are at least one LDAP implementation which does not return error if you try to bind with DN set and empty password - AD.

* Clearing the login/email spaces at the [start/end]
2016-12-12 08:46:51 +08:00
Lunny Xiao
7e88589865 golint fixed for modules/auth 2016-11-27 21:39:06 +08:00
Sandro Santilli
acb138c244 Update import paths from github.com/go-gitea to code.gitea.io (#135)
- Update import paths from github.com/go-gitea to code.gitea.io
- Fix import path for travis

See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
2016-11-10 17:24:48 +01:00
Sandro Santilli
5b2f4f227b Fix type in unused constant name (#111)
* Write LDAP, SMTP, PAM, DLDAP back to all uppercase

* Fix type in unused constant name

* Other MixCased fixes

* Complete MixerCasing of template constants

* Re uppercase LTS and LDAPS suffixes

* Uppercase JSON suffix in constant names

* Proper case LoginNoType

* Prefix unexported template path constants with "tpl"
2016-11-07 18:58:22 -02:00
Sandro Santilli
8a7847982a Security protocols 2016-11-07 17:38:43 +01:00
Rémy Boulanouar
61ec6729e6 Change import reference to match gitea instead of gogs (#37) 2016-11-03 10:29:56 -02:00
Unknwon
bb71191be5 #2709 validate username attribute fetched from LDAP 2016-07-12 07:07:57 +08:00
Unknwon
da9ed19994 Use SecurityProtocol to replace UseSSL in LDAP config
Initially proposed by #2376 and fixes #3068 as well.
2016-07-08 07:25:09 +08:00
Paul Tötterman
263267d911 Add ServerName to tls.Config in LDAP auth (#3104)
From https://godoc.org/crypto/tls#Config

    ServerName is used to verify the hostname on the returned
    certificates unless InsecureSkipVerify is given. It is also included
    in the client's handshake to support virtual hosting unless it is
    an IP address.

This is needed for certificate validation without InsecureSkipVerify.
2016-06-01 01:11:28 -07:00
Adam Strzelecki
a32b5b9bee LDAP: Make a bit more detailed log traces
This is useful especially to check whether we fetch right attributes, using
right LDAP search base and in right order.
2016-02-20 14:12:32 +01:00
Adam Strzelecki
b4bd486184 LDAP: Fetch attributes in Bind DN context option
This is feature is workaround for #2628 (JumpCloud) and some other services
that allow LDAP search only under BindDN user account, but not allow any LDAP
search query in logged user DN context.

Such approach is an alternative to minimal permissions security pattern for
BindDN user.
2016-02-20 14:12:32 +01:00
Adam Strzelecki
72b4e9f776 LDAP: Use single connection in BindDN mode auth
According to RFC 4511 4.2.1. Processing of the Bind Request "Clients may send
multiple Bind requests to change the authentication and/or security
associations or to complete a multi-stage Bind process. Authentication from
earlier binds is subsequently ignored."

Therefore we should not use 2 connections, but single one just sending two bind
requests.
2016-02-20 14:01:47 +01:00
Adam Strzelecki
284d7022e7 Fix #2221 LDAP username attribute must be fetched
This is fix-up for 8d0ee10. Forgot to fetch AttributeUsername value from the
LDAP server, so the setting was effectively not working as intended.
2016-02-07 18:18:29 +01:00
Alex Myasoedov
7b32a12ba8 Fix misspelled words 2015-12-06 16:42:23 +02:00
Adam Strzelecki
8d0ee10100 LDAP: Optional user name attribute specification
Consider following LDAP search query example:

    (&(objectClass=Person)(|(uid=%s)(mail=%s)))

Right now on first login attempt Gogs will use the text supplied on login form
as the newly created user name. In example query above the text matches against
both e-mail or user name. So if user puts the e-mail then the new Gogs user
name will be e-mail which may be undesired.

Using optional user name attribute setting we can explicitly say we want Gogs
user name to be certain LDAP attribute eg. `uid`, so even user will use e-mail
to login 1st time, the new account will receive correct user name.
2015-12-02 00:20:14 +01:00
Unknwon
812a468d0c Use better LDAP lib and should fix #1139 2015-11-26 14:04:58 -05:00
Unknwon
a94538ef3a #1896 fatal when no needed update task 2015-11-04 21:57:10 -05:00
Sergio Benitez
1ba6b60226 Sanitizing input to LDAP authentication module. 2015-10-26 18:08:59 -07:00
Unknwon
380cd2a21c revert simple LDAP userDN and update example 2015-09-16 12:15:14 -04:00
Unknwon
6bf4dbca56 #1637 able to skip verify for LDAP 2015-09-14 15:48:51 -04:00
Unknwon
45011575b5 fix simple LDAP userDN 2015-09-14 12:24:37 -04:00
Sergio Benitez
245c3be8c8 Minor fixes to the LDAP module readme 2015-09-05 15:26:31 -07:00
Sergio Benitez
cb5af2143d Updated the LDAP auth module README. 2015-09-04 21:14:20 -07:00
Sergio Benitez
443a837c01 Added LDAP simple auth support. 2015-09-04 20:48:34 -07:00
Unknwon
b556f5ec05 #1554 check adminFilter length before LDAP search 2015-09-01 08:40:11 -04:00
Girish Ramakrishnan
d4c816bd12 Set IsAdmin using LDAP
The IsAdmin flag is set based on whether the admin filter
returned any result. The admin filter is applied with the user dn
as the search root.

In the future, we should update IsAdmin as well on each login.
Alternately, we can have a periodic sync operation.
2015-08-18 23:49:12 -07:00
Unknwon
f1469ef397 work on #986 and fix a LDAP crash 2015-08-18 04:03:11 +08:00
Sergio Benitez
eba165d3d1 Small style fixes to the LDAP module README 2015-08-16 17:29:56 -07:00
Unknwon
02ebd62ec5 Merge branch 'develop' of https://github.com/SergioBenitez/gogs into develop
# Conflicts:
#	modules/bindata/bindata.go
2015-08-16 14:31:54 +08:00
Sergio Benitez
1a86be7e45 Updated the LDAP module readme. 2015-08-12 17:08:16 -07:00
Sergio Benitez
596eb2ae3e Significantly enhanced LDAP support in Gogs. 2015-08-12 17:01:22 -07:00
Lauris BH
8016fb54d8 Get username, name, surname and e-mail from LDAP server 2015-02-08 01:49:51 +02:00
Joseph Crail
39c068400e Fix spelling errors in comments. 2014-12-06 20:22:48 -05:00
Unknwon
59a7c7c5a5 Remove ldap dep 2014-09-07 20:04:47 -04:00
Tristan Storch
69e332f432 Removed trailing white spaces
Removed trailing whitespaces with

```sh
for file in `grep -r " $" * | cut -d : -f 1 | sort | uniq | grep -v " "`; do sed -i 's/[ \t]*$//' $file; done
```

and some handwork.
2014-08-30 15:12:53 +02:00