Documentation
¶
Index ¶
Constants ¶
const ( // ErrWrongServerSection is the error message for wrong server section. ErrWrongServerSection = "Wrong server section." // ErrWrongGitHubSection is the error message for wrong github section. ErrWrongGitHubSection = "Wrong github section." // ErrWrongUsersSection is the error message for wrong users section. ErrWrongUsersSection = "Wrong users section." // ErrWrongTokensSection is the error message for wrong tokens section. ErrWrongTokensSection = "Wrong tokens section." // ErrWrongServicesSection is the error message for wrong services section. ErrWrongServicesSection = "Wrong services section." // ErrOpeningConfigFile is the error message for opening config file. ErrOpeningConfigFile = "Error opening config file." // ErrDecodingConfigFile is the error message for decoding config file. ErrDecodingConfigFile = "Error decoding config file." // ErrCleaningConfigData is the error message for cleaning config data. ErrCleaningConfigData = "Error cleaning config data." )
const ( ErrEmptyServerTelegramToken = "Telegram token cannot be empty." ErrEmptySsoHost = "SSO host cannot be empty." DEFAULT_KEY_SIZE = 32 )
const ( // ErrEmptyServiceName is the error message for empty service name. ErrEmptyServiceName = "Service name cannot be empty." // ErrEmptyServiceHost is the error message for empty service host. ErrEmptyServiceHost = "Service host cannot be empty." )
const ( // ErrEmptyTokenName is the error message for empty token name. ErrEmptyTokenName = "Token name cannot be empty." // ErrEmptyToken is the error message for empty token. ErrEmptyToken = "Token cannot be empty." )
const ( // ErrEmptyName is the error message for empty name. ErrEmptyUserName = "User name cannot be empty." // ErrEmptyEmail is the error message for empty email. ErrEmptyUserEmail = "User email cannot be empty." // ErrEmptyTelegramId is the error message for empty telegram id. ErrEmptyUserTelegramId = "User telegram id cannot be empty (0)." )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Server Server `toml:"server"`
GitHub GitHub `toml:"github"`
Users []User `toml:"users"`
Tokens []Token `toml:"tokens"`
Services []Service `toml:"services"`
// contains filtered or unexported fields
}
func FromFile ¶
func FromFile(path string) (*Config, errors.TraceableError)
Parse config from toml file.
func (*Config) Clean ¶
func (c *Config) Clean() errors.TraceableError
Clean and validate config data.
func (*Config) FindService ¶
func (*Config) FindUserByGitHub ¶
type GitHub ¶
type GitHub struct {
ClientID string `toml:"client_id"`
ClientSecret string `toml:"client_secret"`
}
func (*GitHub) Clean ¶
func (g *GitHub) Clean() errors.TraceableError
type Server ¶
type Server struct {
ListenAddress string `toml:"listen_address"`
SsoHost string `toml:"sso_host"`
SsoJwtSecret string `toml:"sso_jwt_secret"`
ServicesJwt string `toml:"services_jwt_secret"`
TelegramToken string `toml:"telegram_token"`
// contains filtered or unexported fields
}
Struct Server for [server] section in config file. example: ============================== listen_address = "localhost:5000" sso_host = "auth.example.com" sso_jwt_secret = "example_sso_jwt_secret" services_jwt_secret = "example_services_jwt_secret" telegram_token = "example_telegram_token"
func (*Server) Clean ¶
func (s *Server) Clean() errors.TraceableError
Clean and validate server data.
func (*Server) GetServicesSecretBytes ¶
GetServicesSecretBytes returns the secret bytes for the services JWT.
func (*Server) GetSsoSecretBytes ¶
GetSsoSecretBytes returns the secret bytes for the SSO JWT.
type Service ¶
type Service struct {
Name string `toml:"name"`
Host string `toml:"host"`
Users []string `toml:"users"`
Tokens []string `toml:"tokens"`
Bypass []string `toml:"bypass"`
// contains filtered or unexported fields
}
Struct Service for [[services]] section in config file. example: ============================== name = "code-server" host = "code.example.com" users = [ "john" ] tokens = [ "local-pc", "my-server" ] bypass = [ "/static/", "/some-path/" ]
func (*Service) Clean ¶
func (s *Service) Clean() errors.TraceableError
Clean and validate service data.
func (*Service) IsPathAllowed ¶
Check if path is allowed to bypass the service.
func (*Service) IsTokenAllowed ¶
Check if token is allowed to access the service.
func (*Service) IsUserAllowed ¶
Check if user is allowed to access the service.
type Token ¶
Struct Token for [[tokens]] section in config file. example: ============================== name = "example_token_name" token = "example_token"
func (*Token) Clean ¶
func (t *Token) Clean() errors.TraceableError