Added docker file
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ type Session struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// AuthenticatorService can login users using a separate http service or a temporary in memory store. When a user logs in the auth service returns a session token that can be used to read and modify user properties without having to re-send the user password. (TODO: Not yet implemented: this token has to be renewed every so often otherwise it lasts just a couple of days)
|
||||
// AuthenticatorService can login users using a separate http service or a temporary in memory store. When a user logs in the auth service returns a session token that can be used to read and modify user properties without having to re-send the user password. (TODO: Not yet implemented, this token has to be renewed every so often otherwise it lasts just a couple of days)
|
||||
type AuthenticatorService interface {
|
||||
// GetUser retrieves the user info given the username
|
||||
GetUser(username string) (*User, error)
|
||||
|
||||
+8
-6
@@ -11,8 +11,11 @@ import (
|
||||
|
||||
// ldapUser represents an LDAP User, most fields are inherited from [auth.User]
|
||||
type ldapUser struct {
|
||||
User
|
||||
Uid string `json:"username"`
|
||||
NumericId int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Surname string `json:"surname"`
|
||||
Email string `json:"email"`
|
||||
Role string `json:"role"`
|
||||
Gecos string `json:"gecos"`
|
||||
}
|
||||
@@ -20,11 +23,10 @@ type ldapUser struct {
|
||||
// AsUser converts an [ldapUser] to an instance of [auth.User]
|
||||
func (u ldapUser) AsUser() *User {
|
||||
return &User{
|
||||
Username: u.Username,
|
||||
Username: u.Uid,
|
||||
Name: u.Name,
|
||||
Surname: u.Surname,
|
||||
Email: u.Email,
|
||||
|
||||
FullName: u.Gecos,
|
||||
}
|
||||
}
|
||||
@@ -37,7 +39,7 @@ type LDAPAuthService struct {
|
||||
// doGetRequest is a utility to make HTTP GET requests
|
||||
func (a *LDAPAuthService) doGetRequest(url string, response interface{}) error {
|
||||
req, err := http.NewRequest(
|
||||
"GET", path.Join(a.Host, "ldap", url), bytes.NewBuffer([]byte("")),
|
||||
"GET", path.Join(a.Host, "poisson-ldap", url), bytes.NewBuffer([]byte("")),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@@ -92,7 +94,7 @@ func (a *LDAPAuthService) GetUser(username string) (*User, error) {
|
||||
|
||||
func (a *LDAPAuthService) GetUsers() ([]*User, error) {
|
||||
ldapUsers := []*ldapUser{}
|
||||
if err := a.doGetRequest(fmt.Sprintf("/users"), &ldapUsers); err != nil {
|
||||
if err := a.doGetRequest("/users", &ldapUsers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ func (a *LDAPAuthService) Login(username, password string) (*Session, error) {
|
||||
}
|
||||
|
||||
var response Session
|
||||
if err := a.doPostRequest(fmt.Sprintf("/login"), reqBody, &response); err != nil {
|
||||
if err := a.doPostRequest("/login", reqBody, &response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user