mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 13:44:17 +08:00
* user mgmt models * define user roles * define models for new user mgmt and groups * oauth debug log * initialize user role after db conn * print oauth token in debug log * user roles CRUD apis * user groups CRUD Apis * additional api checks * add additional scopes * add additional scopes url * add additional scopes url * rm additional scopes url * setup middlleware permission checks * integrate permission check into middleware * integrate permission check into middleware * check for headers for subjects * refactor user role models * refactor user groups models * add new user to pending user via RAC login * untracked * allow multiple groups for an user * change json tag * add debug headers * refer network controls form roles, add debug headers * refer network controls form roles, add debug headers * replace auth checks, add network id to role model * nodes handler * migration funcs * invoke sync users migration func * add debug logs * comment middleware * fix get all nodes api * add debug logs * fix middleware error nil check * add new func to get username from jwt * fix jwt parsing * abort on error * allow multiple network roles * allow multiple network roles * add migration func * return err if jwt parsing fails * set global check to true when accessing user apis * set netid for acls api calls * set netid for acls api calls * update role and groups routes * add validation checks * add invite flow apis and magic links * add invited user via oauth signup automatically * create invited user on oauth signup, with groups in the invite * add group validation for user invite * update create user handler with new role mgmt * add validation checks * create user invites tables * add error logging for email invite * fix invite singup url * debug log * get query params from url * get query params from url * add query escape * debug log * debug log * fix user signup via invite api * set admin field for backward compatbility * use new role id for user apis * deprecate use of old admin fields * deprecate usage of old user fields * add user role as service user if empty * setup email sender * delete invite after user singup * add plaform user role * redirect on invite verification link * fix invite redirect * temporary redirect * fix invite redirect * point invite link to frontend * fix query params lookup * add resend support, configure email interface types * fix groups and user creation * validate user groups, add check for metrics api in middleware * add invite url to invite model * migrate rac apis to new user mgmt * handle network nodes * add platform user to default role * fix user role migration * add default on rag creation and cleanup after deletion * fix rac apis * change to invite code param * filter nodes and hosts based on user network access * extend create user group req to accomodate users * filter network based on user access * format oauth error * move user roles and groups * fix get user v1 api * move user mgmt func to pro * add user auth type to user model * fix roles init * remove platform role from group object * list only platform roles * add network roles to invite req * create default groups and roles * fix middleware for global access * create default role * fix nodes filter with global network roles * block selfupdate of groups and network roles * delete netID if net roles are empty * validate user roles nd groups on update * set extclient permission scope when rag vpn access is set * allow deletion of roles and groups * replace _ with - in role naming convention * fix failover middleware mgmt * format oauth templates * fetch route temaplate * return err if user wrong login type * check user groups on rac apis * fix rac apis * fix resp msg * add validation checks for admin invite * return oauth type * format group err msg * fix html tag * clean up default groups * create default rag role * add UI name to roles * remove default net group from user when deleted * reorder migration funcs * fix duplicacy of hosts * check old field for migration * from pro to ce make all secondary users admins * from pro to ce make all secondary users admins * revert: from pro to ce make all secondary users admins * make sure downgrades work * fix pending users approval * fix duplicate hosts * fix duplicate hosts entries * fix cache reference issue * feat: configure FRONTEND_URL during installation * disable user vpn access when network roles are modified * rm vpn acces when roles or groups are deleted * add http to frontend url * revert crypto version * downgrade crytpo version * add platform id check on user invites --------- Co-authored-by: the_aceix <aceixsmartx@gmail.com>
132 lines
5.7 KiB
Go
132 lines
5.7 KiB
Go
// Environment file for getting variables
|
|
// Currently the only thing it does is set the master password
|
|
// Should probably have it take over functions from OS such as port and mongodb connection details
|
|
// Reads from the config/environments/dev.yaml file by default
|
|
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
// setting dev by default
|
|
func getEnv() string {
|
|
env := os.Getenv("NETMAKER_ENV")
|
|
if len(env) == 0 {
|
|
return "dev"
|
|
}
|
|
return env
|
|
}
|
|
|
|
// Config : application config stored as global variable
|
|
var Config *EnvironmentConfig = &EnvironmentConfig{}
|
|
var SetupErr error
|
|
|
|
// EnvironmentConfig - environment conf struct
|
|
type EnvironmentConfig struct {
|
|
Server ServerConfig `yaml:"server"`
|
|
SQL SQLConfig `yaml:"sql"`
|
|
}
|
|
|
|
// ServerConfig - server conf struct
|
|
type ServerConfig struct {
|
|
CoreDNSAddr string `yaml:"corednsaddr"`
|
|
APIConnString string `yaml:"apiconn"`
|
|
APIHost string `yaml:"apihost"`
|
|
APIPort string `yaml:"apiport"`
|
|
Broker string `yam:"broker"`
|
|
ServerBrokerEndpoint string `yaml:"serverbrokerendpoint"`
|
|
BrokerType string `yaml:"brokertype"`
|
|
EmqxRestEndpoint string `yaml:"emqxrestendpoint"`
|
|
NetclientAutoUpdate string `yaml:"netclientautoupdate"`
|
|
NetclientEndpointDetection string `yaml:"netclientendpointdetection"`
|
|
MasterKey string `yaml:"masterkey"`
|
|
DNSKey string `yaml:"dnskey"`
|
|
AllowedOrigin string `yaml:"allowedorigin"`
|
|
NodeID string `yaml:"nodeid"`
|
|
RestBackend string `yaml:"restbackend"`
|
|
MessageQueueBackend string `yaml:"messagequeuebackend"`
|
|
DNSMode string `yaml:"dnsmode"`
|
|
DisableRemoteIPCheck string `yaml:"disableremoteipcheck"`
|
|
Version string `yaml:"version"`
|
|
SQLConn string `yaml:"sqlconn"`
|
|
Platform string `yaml:"platform"`
|
|
Database string `yaml:"database"`
|
|
Verbosity int32 `yaml:"verbosity"`
|
|
AuthProvider string `yaml:"authprovider"`
|
|
OIDCIssuer string `yaml:"oidcissuer"`
|
|
ClientID string `yaml:"clientid"`
|
|
ClientSecret string `yaml:"clientsecret"`
|
|
FrontendURL string `yaml:"frontendurl"`
|
|
DisplayKeys string `yaml:"displaykeys"`
|
|
AzureTenant string `yaml:"azuretenant"`
|
|
Telemetry string `yaml:"telemetry"`
|
|
HostNetwork string `yaml:"hostnetwork"`
|
|
Server string `yaml:"server"`
|
|
PublicIPService string `yaml:"publicipservice"`
|
|
MQPassword string `yaml:"mqpassword"`
|
|
MQUserName string `yaml:"mqusername"`
|
|
MetricsExporter string `yaml:"metrics_exporter"`
|
|
BasicAuth string `yaml:"basic_auth"`
|
|
LicenseValue string `yaml:"license_value"`
|
|
NetmakerTenantID string `yaml:"netmaker_tenant_id"`
|
|
IsPro string `yaml:"is_ee" json:"IsEE"`
|
|
StunPort int `yaml:"stun_port"`
|
|
StunList string `yaml:"stun_list"`
|
|
TurnServer string `yaml:"turn_server"`
|
|
TurnApiServer string `yaml:"turn_api_server"`
|
|
TurnPort int `yaml:"turn_port"`
|
|
TurnUserName string `yaml:"turn_username"`
|
|
TurnPassword string `yaml:"turn_password"`
|
|
UseTurn bool `yaml:"use_turn"`
|
|
UsersLimit int `yaml:"user_limit"`
|
|
NetworksLimit int `yaml:"network_limit"`
|
|
MachinesLimit int `yaml:"machines_limit"`
|
|
IngressesLimit int `yaml:"ingresses_limit"`
|
|
EgressesLimit int `yaml:"egresses_limit"`
|
|
DeployedByOperator bool `yaml:"deployed_by_operator"`
|
|
Environment string `yaml:"environment"`
|
|
JwtValidityDuration time.Duration `yaml:"jwt_validity_duration"`
|
|
RacAutoDisable bool `yaml:"rac_auto_disable"`
|
|
CacheEnabled string `yaml:"caching_enabled"`
|
|
EndpointDetection bool `json:"endpoint_detection"`
|
|
AllowedEmailDomains string `yaml:"allowed_email_domains"`
|
|
EmailSenderAddr string `json:"email_sender_addr"`
|
|
EmailSenderAuth string `json:"email_sender_auth"`
|
|
EmailSenderType string `json:"email_sender_type"`
|
|
SmtpHost string `json:"smtp_host"`
|
|
SmtpPort int `json:"smtp_port"`
|
|
MetricInterval string `yaml:"metric_interval"`
|
|
}
|
|
|
|
// SQLConfig - Generic SQL Config
|
|
type SQLConfig struct {
|
|
Host string `yaml:"host"`
|
|
Port int32 `yaml:"port"`
|
|
Username string `yaml:"username"`
|
|
Password string `yaml:"password"`
|
|
DB string `yaml:"db"`
|
|
SSLMode string `yaml:"sslmode"`
|
|
}
|
|
|
|
// reading in the env file
|
|
func ReadConfig(absolutePath string) (*EnvironmentConfig, error) {
|
|
if len(absolutePath) == 0 {
|
|
absolutePath = fmt.Sprintf("environments/%s.yaml", getEnv())
|
|
}
|
|
f, err := os.Open(absolutePath)
|
|
var cfg EnvironmentConfig
|
|
if err != nil {
|
|
return &cfg, err
|
|
}
|
|
defer f.Close()
|
|
|
|
decoder := yaml.NewDecoder(f)
|
|
if decoder.Decode(&cfg) != nil {
|
|
return &cfg, err
|
|
}
|
|
return &cfg, err
|
|
}
|