-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved NTLM to rdpgw-auth to avoid accessing passwords in main program
NTLM tests added NTLM licensing info added Avoid logging NTLM messages as it may contain sensitive information Renamed database authentication to NTLM as requested by bolkedebruin (see PR #109)
- Loading branch information
Showing
15 changed files
with
817 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/knadh/koanf/parsers/yaml" | ||
"github.com/knadh/koanf/providers/confmap" | ||
"github.com/knadh/koanf/providers/file" | ||
"github.com/knadh/koanf/v2" | ||
"log" | ||
"os" | ||
) | ||
|
||
type Configuration struct { | ||
Users []UserConfig `koanf:"users"` | ||
} | ||
|
||
type UserConfig struct { | ||
Username string `koanf:"username"` | ||
Password string `koanf:"password"` | ||
} | ||
|
||
var Conf Configuration | ||
|
||
func Load(configFile string) Configuration { | ||
|
||
var k = koanf.New(".") | ||
|
||
k.Load(confmap.Provider(map[string]interface{}{}, "."), nil) | ||
|
||
if _, err := os.Stat(configFile); os.IsNotExist(err) { | ||
log.Printf("Config file %s not found, skipping config file", configFile) | ||
} else { | ||
if err := k.Load(file.Provider(configFile), yaml.Parser()); err != nil { | ||
log.Fatalf("Error loading config from file: %v", err) | ||
} | ||
} | ||
|
||
koanfTag := koanf.UnmarshalConf{Tag: "koanf"} | ||
k.UnmarshalWithConf("Users", &Conf.Users, koanfTag) | ||
|
||
return Conf | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/bolkedebruin/rdpgw/cmd/auth/config" | ||
"testing" | ||
) | ||
|
||
func createTestDatabase () (Database) { | ||
var users = []config.UserConfig{} | ||
|
||
user1 := config.UserConfig{} | ||
user1.Username = "my_username" | ||
user1.Password = "my_password" | ||
users = append(users, user1) | ||
|
||
user2 := config.UserConfig{} | ||
user2.Username = "my_username2" | ||
user2.Password = "my_password2" | ||
users = append(users, user2) | ||
|
||
config := NewConfig(users) | ||
|
||
return config | ||
} | ||
|
||
func TestDatabaseConfigValidUsername(t *testing.T) { | ||
database := createTestDatabase() | ||
|
||
if database.GetPassword("my_username") != "my_password" { | ||
t.Fatalf("Wrong password returned") | ||
} | ||
if database.GetPassword("my_username2") != "my_password2" { | ||
t.Fatalf("Wrong password returned") | ||
} | ||
} | ||
|
||
func TestDatabaseInvalidUsername(t *testing.T) { | ||
database := createTestDatabase() | ||
|
||
if database.GetPassword("my_invalid_username") != "" { | ||
t.Fatalf("Non empty password returned for invalid username") | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.