mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
* api - add OperationID helps when using pyswagger and is visible via http://localhost:8123/swagger/index.html?displayOperationId=true gin-swagger can not set displayOperationId yet * api - match paramters to their property equivalents pascalcase & sometimes replacing the name (e.g. device -> DeviceName) * api - use ShouldBindJSON instead of BindJSON BindJSON sets the content-type text/plain * api - we renamed, we regenerated * device - allow - in DeviceName wg-example0.conf etc * api - more pascalcase & argument renames * api - marshal DeletedAt as string gorm.DeletedAt is of type sql.NullTime NullTime declares Time & Valid as properties DeletedAt marshals as time.Time swaggertype allows only basic types -> string * Peer - export UID/DeviceType in json UID/DeviceType is required, skipping in json, skips it in marshalling, next unmarshalling fails * assets - name forms for use with mechanize * api - match error message * add python3/pyswagger based unittesting - initializes a clean install by configuration via web service - tests the rest api * tests - test address exhaustion * tests - test network expansion Co-authored-by: Markus Koetter <koetter@cispa.de>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package users
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type UserSource string
|
|
|
|
const (
|
|
UserSourceLdap UserSource = "ldap" // LDAP / ActiveDirectory
|
|
UserSourceDatabase UserSource = "db" // sqlite / mysql database
|
|
UserSourceOIDC UserSource = "oidc" // open id connect, TODO: implement
|
|
)
|
|
|
|
type PrivateString string
|
|
|
|
func (PrivateString) MarshalJSON() ([]byte, error) {
|
|
return []byte(`""`), nil
|
|
}
|
|
|
|
func (PrivateString) String() string {
|
|
return ""
|
|
}
|
|
|
|
// User is the user model that gets linked to peer entries, by default an empty usermodel with only the email address is created
|
|
type User struct {
|
|
// required fields
|
|
Email string `gorm:"primaryKey" form:"email" binding:"required,email"`
|
|
Source UserSource
|
|
IsAdmin bool
|
|
|
|
// optional fields
|
|
Firstname string `form:"firstname" binding:"required"`
|
|
Lastname string `form:"lastname" binding:"required"`
|
|
Phone string `form:"phone" binding:"omitempty"`
|
|
|
|
// optional, integrated password authentication
|
|
Password PrivateString `form:"password" binding:"omitempty"`
|
|
|
|
// database internal fields
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:",omitempty" swaggertype:"string"`
|
|
}
|