Documentation ¶
Index ¶
- Constants
- Variables
- func DestroySessionData(c *gin.Context) error
- func SetFlashMessage(c *gin.Context, message, typ string)
- func SetupApiRoutes(s *Server)
- func SetupRoutes(s *Server)
- func UpdateSessionData(c *gin.Context, data SessionData) error
- type ApiError
- type ApiServer
- func (s *ApiServer) DeletePeer(c *gin.Context)
- func (s *ApiServer) DeleteUser(c *gin.Context)
- func (s *ApiServer) GetDevice(c *gin.Context)
- func (s *ApiServer) GetDevices(c *gin.Context)
- func (s *ApiServer) GetPeer(c *gin.Context)
- func (s *ApiServer) GetPeerDeploymentConfig(c *gin.Context)
- func (s *ApiServer) GetPeerDeploymentInformation(c *gin.Context)
- func (s *ApiServer) GetPeers(c *gin.Context)
- func (s *ApiServer) GetUser(c *gin.Context)
- func (s *ApiServer) GetUsers(c *gin.Context)
- func (s *ApiServer) PatchDevice(c *gin.Context)
- func (s *ApiServer) PatchPeer(c *gin.Context)
- func (s *ApiServer) PatchUser(c *gin.Context)
- func (s *ApiServer) PostPeer(c *gin.Context)
- func (s *ApiServer) PostPeerDeploymentConfig(c *gin.Context)
- func (s *ApiServer) PostUser(c *gin.Context)
- func (s *ApiServer) PutDevice(c *gin.Context)
- func (s *ApiServer) PutPeer(c *gin.Context)
- func (s *ApiServer) PutUser(c *gin.Context)
- type AuthManager
- func (auth *AuthManager) GetProvider(name string) authentication.AuthProvider
- func (auth *AuthManager) GetProviders() (providers []authentication.AuthProvider)
- func (auth *AuthManager) GetProvidersForType(typ authentication.AuthProviderType) (providers []authentication.AuthProvider)
- func (auth *AuthManager) RegisterProvider(provider authentication.AuthProvider)
- func (auth *AuthManager) RegisterProviderWithoutError(provider authentication.AuthProvider, err error)
- type Config
- type FlashData
- type LdapCreateForm
- type PeerDeploymentInformation
- type ProvisioningRequest
- type Server
- func (s *Server) CreatePeer(device string, peer wireguard.Peer) error
- func (s *Server) CreatePeerByEmail(device, email, identifierSuffix string) error
- func (s *Server) CreateUser(user users.User, device string) error
- func (s *Server) CreateUserDefaultPeer(email, device string) error
- func (s *Server) DeletePeer(peer wireguard.Peer) error
- func (s *Server) DeleteUser(user users.User) error
- func (s *Server) GetAdminCreateLdapPeers(c *gin.Context)
- func (s *Server) GetAdminCreatePeer(c *gin.Context)
- func (s *Server) GetAdminDeletePeer(c *gin.Context)
- func (s *Server) GetAdminEditInterface(c *gin.Context)
- func (s *Server) GetAdminEditPeer(c *gin.Context)
- func (s *Server) GetAdminIndex(c *gin.Context)
- func (s *Server) GetAdminSendEmails(c *gin.Context)
- func (s *Server) GetAdminUsersCreate(c *gin.Context)
- func (s *Server) GetAdminUsersDelete(c *gin.Context)
- func (s *Server) GetAdminUsersEdit(c *gin.Context)
- func (s *Server) GetAdminUsersIndex(c *gin.Context)
- func (s *Server) GetApplyGlobalConfig(c *gin.Context)
- func (s *Server) GetDeviceNames() map[string]string
- func (s *Server) GetHandleError(c *gin.Context, code int, message, details string)
- func (s *Server) GetIndex(c *gin.Context)
- func (s *Server) GetInterfaceConfig(c *gin.Context)
- func (s *Server) GetLogin(c *gin.Context)
- func (s *Server) GetLogout(c *gin.Context)
- func (s *Server) GetPeerConfig(c *gin.Context)
- func (s *Server) GetPeerConfigMail(c *gin.Context)
- func (s *Server) GetPeerQRCode(c *gin.Context)
- func (s *Server) GetPeerStatus(c *gin.Context)
- func (s *Server) GetSaveConfig(c *gin.Context)
- func (s *Server) GetUserCreatePeer(c *gin.Context)
- func (s *Server) GetUserEditPeer(c *gin.Context)
- func (s *Server) GetUserIndex(c *gin.Context)
- func (s *Server) HardDeleteUser(user users.User) error
- func (s *Server) PostAdminCreateLdapPeers(c *gin.Context)
- func (s *Server) PostAdminCreatePeer(c *gin.Context)
- func (s *Server) PostAdminEditInterface(c *gin.Context)
- func (s *Server) PostAdminEditPeer(c *gin.Context)
- func (s *Server) PostAdminUsersCreate(c *gin.Context)
- func (s *Server) PostAdminUsersEdit(c *gin.Context)
- func (s *Server) PostLogin(c *gin.Context)
- func (s *Server) PostUserCreatePeer(c *gin.Context)
- func (s *Server) PostUserEditPeer(c *gin.Context)
- func (s *Server) PrepareNewPeer(device string) (wireguard.Peer, error)
- func (s *Server) RequireApiAuthentication(scope string) gin.HandlerFunc
- func (s *Server) RequireAuthentication(scope string) gin.HandlerFunc
- func (s *Server) RestoreWireGuardInterface(device string) error
- func (s *Server) Run()
- func (s *Server) RunBackgroundTasks(ctx context.Context)
- func (s *Server) Setup(ctx context.Context) error
- func (s *Server) SyncLdapWithUserDatabase()
- func (s *Server) UpdatePeer(peer wireguard.Peer, updateTime time.Time) error
- func (s *Server) UpdateUser(user users.User) error
- func (s *Server) WriteWireGuardConfigFile(device string) error
- type SessionData
- type StaticData
Constants ¶
const SessionIdentifier = "wgPortalSession"
Variables ¶
var DatabaseVersion = "1.0.9"
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")
var Version = "testbuild"
Functions ¶
func DestroySessionData ¶ added in v1.0.3
func SetFlashMessage ¶ added in v1.0.3
func SetupApiRoutes ¶ added in v1.0.8
func SetupApiRoutes(s *Server)
func SetupRoutes ¶
func SetupRoutes(s *Server)
func UpdateSessionData ¶ added in v1.0.3
func UpdateSessionData(c *gin.Context, data SessionData) error
Types ¶
type ApiServer ¶ added in v1.0.8
type ApiServer struct {
// contains filtered or unexported fields
}
ApiServer is a simple wrapper struct so that we can have fresh member function names.
func (*ApiServer) DeletePeer ¶ added in v1.0.8
DeletePeer godoc @Tags Peers @Summary Updates the given peer based on the given partial peer model @ID DeletePeer @Produce json @Param PublicKey query string true "Public Key" @Success 204 "No Content" @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/peer [delete] @Security ApiBasicAuth
func (*ApiServer) DeleteUser ¶ added in v1.0.8
DeleteUser godoc @Tags Users @Summary Deletes the specified user @ID DeleteUser @Produce json @Param Email query string true "User Email" @Success 204 "No content" @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/user [delete] @Security ApiBasicAuth
func (*ApiServer) GetDevice ¶ added in v1.0.8
GetDevice godoc @Tags Interface @Summary Get the given device @ID GetDevice @Produce json @Param DeviceName query string true "Device Name" @Success 200 {object} wireguard.Device @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/device [get] @Security ApiBasicAuth
func (*ApiServer) GetDevices ¶ added in v1.0.8
GetDevices godoc @Tags Interface @Summary Get all devices @ID GetDevices @Produce json @Success 200 {object} []wireguard.Device @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/devices [get] @Security ApiBasicAuth
func (*ApiServer) GetPeer ¶ added in v1.0.8
GetPeer godoc @Tags Peers @Summary Retrieves the peer for the given public key @ID GetPeer @Produce json @Param PublicKey query string true "Public Key (Base 64)" @Success 200 {object} wireguard.Peer @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/peer [get] @Security ApiBasicAuth
func (*ApiServer) GetPeerDeploymentConfig ¶ added in v1.0.8
GetPeerDeploymentConfig godoc @Tags Provisioning @Summary Retrieves the peer config for the given public key @ID GetPeerDeploymentConfig @Produce plain @Param PublicKey query string true "Public Key (Base 64)" @Success 200 {object} string "The WireGuard configuration file" @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /provisioning/peer [get] @Security GeneralBasicAuth
func (*ApiServer) GetPeerDeploymentInformation ¶ added in v1.0.8
GetPeerDeploymentInformation godoc @Tags Provisioning @Summary Retrieves all active peers for the given email address @ID GetPeerDeploymentInformation @Produce json @Param Email query string true "Email Address" @Success 200 {object} []PeerDeploymentInformation "All active WireGuard peers" @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /provisioning/peers [get] @Security GeneralBasicAuth
func (*ApiServer) GetPeers ¶ added in v1.0.8
GetPeers godoc @Tags Peers @Summary Retrieves all peers for the given interface @ID GetPeers @Produce json @Param DeviceName query string true "Device Name" @Success 200 {object} []wireguard.Peer @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/peers [get] @Security ApiBasicAuth
func (*ApiServer) GetUser ¶ added in v1.0.8
GetUser godoc @Tags Users @Summary Retrieves user based on given Email @ID GetUser @Produce json @Param Email query string true "User Email" @Success 200 {object} users.User @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/user [get] @Security ApiBasicAuth
func (*ApiServer) GetUsers ¶ added in v1.0.8
GetUsers godoc @Tags Users @Summary Retrieves all users @ID GetUsers @Produce json @Success 200 {object} []users.User @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /backend/users [get] @Security ApiBasicAuth
func (*ApiServer) PatchDevice ¶ added in v1.0.8
PatchDevice godoc @Tags Interface @Summary Updates the given device based on the given partial device model (UNIMPLEMENTED) @ID PatchDevice @Accept json @Produce json @Param DeviceName query string true "Device Name" @Param Device body wireguard.Device true "Device Model" @Success 200 {object} wireguard.Device @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/device [patch] @Security ApiBasicAuth
func (*ApiServer) PatchPeer ¶ added in v1.0.8
PatchPeer godoc @Tags Peers @Summary Updates the given peer based on the given partial peer model @ID PatchPeer @Accept json @Produce json @Param PublicKey query string true "Public Key" @Param Peer body wireguard.Peer true "Peer Model" @Success 200 {object} wireguard.Peer @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/peer [patch] @Security ApiBasicAuth
func (*ApiServer) PatchUser ¶ added in v1.0.8
PatchUser godoc @Tags Users @Summary Updates a user based on the given partial user model @ID PatchUser @Accept json @Produce json @Param Email query string true "User Email" @Param User body users.User true "User Model" @Success 200 {object} users.User @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/user [patch] @Security ApiBasicAuth
func (*ApiServer) PostPeer ¶ added in v1.0.8
PostPeer godoc @Tags Peers @Summary Creates a new peer based on the given peer model @ID PostPeer @Accept json @Produce json @Param DeviceName query string true "Device Name" @Param Peer body wireguard.Peer true "Peer Model" @Success 200 {object} wireguard.Peer @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/peers [post] @Security ApiBasicAuth
func (*ApiServer) PostPeerDeploymentConfig ¶ added in v1.0.8
PostPeerDeploymentConfig godoc @Tags Provisioning @Summary Creates the requested peer config and returns the config file @ID PostPeerDeploymentConfig @Accept json @Produce plain @Param ProvisioningRequest body ProvisioningRequest true "Provisioning Request Model" @Success 200 {object} string "The WireGuard configuration file" @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Router /provisioning/peers [post] @Security GeneralBasicAuth
func (*ApiServer) PostUser ¶ added in v1.0.8
PostUser godoc @Tags Users @Summary Creates a new user based on the given user model @ID PostUser @Accept json @Produce json @Param User body users.User true "User Model" @Success 200 {object} users.User @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/users [post] @Security ApiBasicAuth
func (*ApiServer) PutDevice ¶ added in v1.0.8
PutDevice godoc @Tags Interface @Summary Updates the given device based on the given device model (UNIMPLEMENTED) @ID PutDevice @Accept json @Produce json @Param DeviceName query string true "Device Name" @Param Device body wireguard.Device true "Device Model" @Success 200 {object} wireguard.Device @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/device [put] @Security ApiBasicAuth
func (*ApiServer) PutPeer ¶ added in v1.0.8
PutPeer godoc @Tags Peers @Summary Updates the given peer based on the given peer model @ID PutPeer @Accept json @Produce json @Param PublicKey query string true "Public Key" @Param Peer body wireguard.Peer true "Peer Model" @Success 200 {object} wireguard.Peer @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/peer [put] @Security ApiBasicAuth
func (*ApiServer) PutUser ¶ added in v1.0.8
PutUser godoc @Tags Users @Summary Updates a user based on the given user model @ID PutUser @Accept json @Produce json @Param Email query string true "User Email" @Param User body users.User true "User Model" @Success 200 {object} users.User @Failure 400 {object} ApiError @Failure 401 {object} ApiError @Failure 403 {object} ApiError @Failure 404 {object} ApiError @Failure 500 {object} ApiError @Router /backend/user [put] @Security ApiBasicAuth
type AuthManager ¶ added in v1.0.3
type AuthManager struct { Server *Server Group *gin.RouterGroup // basic group for all providers (/auth) UserManager *users.Manager // contains filtered or unexported fields }
AuthManager keeps track of available authentication providers.
func NewAuthManager ¶ added in v1.0.3
func NewAuthManager(server *Server) *AuthManager
func (*AuthManager) GetProvider ¶ added in v1.0.3
func (auth *AuthManager) GetProvider(name string) authentication.AuthProvider
GetProvider get provider by name
func (*AuthManager) GetProviders ¶ added in v1.0.3
func (auth *AuthManager) GetProviders() (providers []authentication.AuthProvider)
GetProviders return registered providers. Returned providers are ordered by provider priority.
func (*AuthManager) GetProvidersForType ¶ added in v1.0.3
func (auth *AuthManager) GetProvidersForType(typ authentication.AuthProviderType) (providers []authentication.AuthProvider)
GetProvidersForType return registered providers for the given type. Returned providers are ordered by provider priority.
func (*AuthManager) RegisterProvider ¶ added in v1.0.3
func (auth *AuthManager) RegisterProvider(provider authentication.AuthProvider)
RegisterProvider register auth provider
func (*AuthManager) RegisterProviderWithoutError ¶ added in v1.0.3
func (auth *AuthManager) RegisterProviderWithoutError(provider authentication.AuthProvider, err error)
RegisterProviderWithoutError register auth provider if err is nil
type Config ¶ added in v1.0.4
type Config struct { Core struct { ListeningAddress string `yaml:"listeningAddress" envconfig:"LISTENING_ADDRESS"` ExternalUrl string `yaml:"externalUrl" envconfig:"EXTERNAL_URL"` Title string `yaml:"title" envconfig:"WEBSITE_TITLE"` CompanyName string `yaml:"company" envconfig:"COMPANY_NAME"` MailFrom string `yaml:"mailFrom" envconfig:"MAIL_FROM"` AdminUser string `yaml:"adminUser" envconfig:"ADMIN_USER"` // must be an email address AdminPassword string `yaml:"adminPass" envconfig:"ADMIN_PASS"` EditableKeys bool `yaml:"editableKeys" envconfig:"EDITABLE_KEYS"` CreateDefaultPeer bool `yaml:"createDefaultPeer" envconfig:"CREATE_DEFAULT_PEER"` SelfProvisioningAllowed bool `yaml:"selfProvisioning" envconfig:"SELF_PROVISIONING"` WGExporterFriendlyNames bool `yaml:"wgExporterFriendlyNames" envconfig:"WG_EXPORTER_FRIENDLY_NAMES"` LdapEnabled bool `yaml:"ldapEnabled" envconfig:"LDAP_ENABLED"` SessionSecret string `yaml:"sessionSecret" envconfig:"SESSION_SECRET"` LogoUrl string `yaml:"logoUrl" envconfig:"LOGO_URL"` BackgroundTaskInterval int `yaml:"backgroundTaskInterval" envconfig:"BACKGROUND_TASK_INTERVAL"` // in seconds ExpiryReEnable bool `yaml:"expiryReEnable" envconfig:"EXPIRY_REENABLE"` } `yaml:"core"` Database common.DatabaseConfig `yaml:"database"` Email common.MailConfig `yaml:"email"` LDAP ldap.Config `yaml:"ldap"` WG wireguard.Config `yaml:"wg"` }
type FlashData ¶
func GetFlashes ¶ added in v1.0.3
type LdapCreateForm ¶
type PeerDeploymentInformation ¶ added in v1.0.8
type ProvisioningRequest ¶ added in v1.0.8
type ProvisioningRequest struct { // DeviceName is optional, if not specified, the configured default device will be used. DeviceName string `json:",omitempty"` Identifier string `binding:"required"` Email string `binding:"required"` AllowedIPsStr string `binding:"cidrlist" json:",omitempty"` PersistentKeepalive int `binding:"gte=0" json:",omitempty"` DNSStr string `binding:"iplist" json:",omitempty"` Mtu int `binding:"gte=0,lte=1500" json:",omitempty"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CreatePeer ¶ added in v1.0.3
CreatePeer creates the new peer in the database. If the peer has no assigned ip addresses, a new one will be assigned automatically. Also, if the private key is empty, a new key-pair will be generated. This function also configures the new peer on the physical WireGuard interface if the peer is not deactivated.
func (*Server) CreatePeerByEmail ¶ added in v1.0.3
CreatePeerByEmail creates a new peer for the given email.
func (*Server) CreateUser ¶
CreateUser creates the user in the database and optionally adds a default WireGuard peer for the user.
func (*Server) CreateUserDefaultPeer ¶ added in v1.0.3
func (*Server) DeletePeer ¶ added in v1.0.3
DeletePeer removes the peer from the physical WireGuard interface and the database.
func (*Server) DeleteUser ¶
DeleteUser soft-deletes the user from the database (disable the user). Also, if the user has linked WireGuard peers, they will be deactivated.
func (*Server) GetAdminCreateLdapPeers ¶
func (*Server) GetAdminCreatePeer ¶
func (*Server) GetAdminDeletePeer ¶
func (*Server) GetAdminEditInterface ¶
func (*Server) GetAdminEditPeer ¶
func (*Server) GetAdminIndex ¶
func (*Server) GetAdminSendEmails ¶ added in v1.0.11
func (*Server) GetAdminUsersCreate ¶ added in v1.0.3
func (*Server) GetAdminUsersDelete ¶ added in v1.0.14
func (*Server) GetAdminUsersEdit ¶ added in v1.0.3
func (*Server) GetAdminUsersIndex ¶ added in v1.0.3
func (*Server) GetApplyGlobalConfig ¶
func (*Server) GetDeviceNames ¶ added in v1.0.5
func (*Server) GetHandleError ¶
func (*Server) GetInterfaceConfig ¶
func (*Server) GetPeerConfig ¶
func (*Server) GetPeerConfigMail ¶
func (*Server) GetPeerQRCode ¶
func (*Server) GetPeerStatus ¶
func (*Server) GetSaveConfig ¶ added in v1.0.5
func (*Server) GetUserCreatePeer ¶ added in v1.0.15
func (*Server) GetUserEditPeer ¶ added in v1.0.15
func (*Server) GetUserIndex ¶
func (*Server) HardDeleteUser ¶ added in v1.0.14
HardDeleteUser removes the user from the database. Also, if the user has linked WireGuard peers, they will be deleted.
func (*Server) PostAdminCreateLdapPeers ¶
func (*Server) PostAdminCreatePeer ¶
func (*Server) PostAdminEditInterface ¶
func (*Server) PostAdminEditPeer ¶
func (*Server) PostAdminUsersCreate ¶ added in v1.0.3
func (*Server) PostAdminUsersEdit ¶ added in v1.0.3
func (*Server) PostUserCreatePeer ¶ added in v1.0.15
func (*Server) PostUserEditPeer ¶ added in v1.0.15
func (*Server) PrepareNewPeer ¶ added in v1.0.3
PrepareNewPeer initiates a new peer for the given WireGuard device.
func (*Server) RequireApiAuthentication ¶ added in v1.0.8
func (s *Server) RequireApiAuthentication(scope string) gin.HandlerFunc
func (*Server) RequireAuthentication ¶
func (s *Server) RequireAuthentication(scope string) gin.HandlerFunc
func (*Server) RestoreWireGuardInterface ¶
RestoreWireGuardInterface restores the state of the physical WireGuard interface from the database.
func (*Server) RunBackgroundTasks ¶ added in v1.0.16
func (*Server) SyncLdapWithUserDatabase ¶ added in v1.0.3
func (s *Server) SyncLdapWithUserDatabase()
func (*Server) UpdatePeer ¶ added in v1.0.3
UpdatePeer updates the physical WireGuard interface and the database.
func (*Server) UpdateUser ¶
UpdateUser updates the user in the database. If the user is marked as deleted, it will get remove from the database. Also, if the user is re-enabled, all it's linked WireGuard peers will be activated again.
func (*Server) WriteWireGuardConfigFile ¶
WriteWireGuardConfigFile writes the configuration file for the physical WireGuard interface.
type SessionData ¶
type SessionData struct { LoggedIn bool IsAdmin bool Firstname string Lastname string Email string DeviceName string SortedBy map[string]string SortDirection map[string]string Search map[string]string AlertData string AlertType string FormData interface{} }
func GetSessionData ¶ added in v1.0.3
func GetSessionData(c *gin.Context) SessionData
func (SessionData) GetSortIcon ¶
func (s SessionData) GetSortIcon(table, field string) string