Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Admin attribute based on LDAP when login (continue #1743) #8849

Merged
merged 39 commits into from
Nov 14, 2019
Merged
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9ed9f6e
Update User information in Gitea based on LDAP when login
DblK May 17, 2017
f15fcbf
Update Admin Flag only if exist in settings
DblK May 18, 2017
879b5f7
Fix affectation
remy-wanteeed Oct 28, 2019
d0f465e
Update models/login_source.go
DblK Oct 28, 2019
18bc2a2
Merge branch 'feature_UpdateUserInfoOnLDAP' of https://github.com/Dbl…
remy-wanteeed Oct 28, 2019
db57637
Better ident
remy-wanteeed Oct 29, 2019
e9d9244
Apply suggestions from code review
DblK Nov 1, 2019
89f0006
Make fmt
remy-wanteeed Nov 3, 2019
f30e4a1
add err handling
6543 Nov 5, 2019
f434972
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 5, 2019
ef1054f
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 6, 2019
d6a30be
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 7, 2019
1657a62
if user exist but login is Prohibit return return nil, and Prohibit err
6543 Nov 7, 2019
7ab74eb
keep login speed
6543 Nov 7, 2019
6c703ff
User sync is implemented at #1478 - so only make sure that admin acce…
6543 Nov 7, 2019
a589d75
handle error and still use async task
6543 Nov 7, 2019
5c3b8e9
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 8, 2019
d39606e
no async
6543 Nov 8, 2019
406a7bf
only update admin if Sync is enabled
6543 Nov 8, 2019
d5556fd
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 8, 2019
fb2f9a4
update two comments
6543 Nov 8, 2019
66d7857
add lafriks suggestions
6543 Nov 9, 2019
cdb94ca
if adminFilter is set - use it
6543 Nov 9, 2019
11dc5d3
Update models/login_source.go
6543 Nov 9, 2019
8af9ed7
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 10, 2019
c73ce44
make it work again
6543 Nov 10, 2019
bd1d5cc
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 10, 2019
8492f8c
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 10, 2019
b76135d
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 11, 2019
b018774
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
lunny Nov 11, 2019
ca79841
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
zeripath Nov 11, 2019
0112c77
set is_admin value to user
6543 Nov 13, 2019
eef26b2
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 13, 2019
9d255ed
look nicer
6543 Nov 13, 2019
6753b3d
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
techknowlogick Nov 14, 2019
2ea1435
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 14, 2019
321b5aa
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
6543 Nov 14, 2019
da6f213
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
techknowlogick Nov 14, 2019
7495aa5
Merge branch 'master' into feature_UpdateUserInfoOnLDAP
techknowlogick Nov 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions models/login_source.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -403,6 +404,19 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR

var isAttributeSSHPublicKeySet = len(strings.TrimSpace(source.LDAP().AttributeSSHPublicKey)) > 0

// Update User admin flag if exist
6543 marked this conversation as resolved.
Show resolved Hide resolved
if isExist, err := IsUserExist(0, sr.Username); err != nil {
return nil, err
} else if isExist &&
!user.ProhibitLogin && len(source.LDAP().AdminFilter) > 0 && user.IsAdmin != sr.IsAdmin {
// Change existing admin flag only if AdminFilter option is set
user.IsAdmin = sr.IsAdmin
err = UpdateUserCols(user, "is_admin")
6543 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
}
6543 marked this conversation as resolved.
Show resolved Hide resolved

if !autoRegister {
if isAttributeSSHPublicKeySet && synchronizeLdapSSHPublicKeys(user, source, sr.SSHPublicKey) {
return user, RewriteAllPublicKeys()
Expand Down