Skip to content

Commit

Permalink
Fix pre-Windows 2000 logon for username (issue #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
abbas-gheydi committed Feb 13, 2024
1 parent fb7310a commit 95faf0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions pkgs/authentiate/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ func (l LdapProvider) isUserAuthorized(groups []string) bool {
}

func (l LdapProvider) IsUserAuthenticated(username string, password string, checkForVendorFortinetGroup bool) (isAuthenticated bool, vendorFortinetGroupName []string) {

if strings.Contains(username, "\\") {
splitChar := "\\"
username = strings.Split(username, splitChar)[0]
winNTSplitChar := "\\"
if strings.Contains(username, winNTSplitChar) && strings.Split(username, winNTSplitChar)[1] != "" {
username = strings.Split(username, winNTSplitChar)[1]
}

verifyPasswordAndRetrieveGroupsFromLdap := func(groups []string) (isAuthenticated bool, joinedGroupsName []string, err error) {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/storage/postgres_otp.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func (p postgresOtp) Delete(username string) error {

func (p postgresOtp) Get(username string) (password string, err error) {
username = strings.ToLower(username)
if strings.Contains(username, "\\") {
splitChar := "\\"
username = strings.Split(username, splitChar)[0]
winNTSplitChar := "\\"
if strings.Contains(username, winNTSplitChar) && strings.Split(username, winNTSplitChar)[1] != "" {
username = strings.Split(username, winNTSplitChar)[1]
}
otpUser := otps{Username: username}

Expand Down

0 comments on commit 95faf0d

Please sign in to comment.