You've already forked focalboard
mirror of
https://github.com/mattermost/focalboard.git
synced 2025-07-12 23:50:27 +02:00
Move single-user-token to environment var
This commit is contained in:
@ -15,10 +15,12 @@ import (
|
|||||||
var sessionToken string = "su-" + uuid.New().String()
|
var sessionToken string = "su-" + uuid.New().String()
|
||||||
|
|
||||||
func runServer(ctx context.Context) {
|
func runServer(ctx context.Context) {
|
||||||
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
|
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user")
|
||||||
|
cmd.Env = []string{fmt.Sprintf("FOCALBOARD_SINGLE_USER_TOKEN=%s", sessionToken)}
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("Failed to start server")
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
log.Printf("Just ran subprocess %d, exiting\n", cmd.Process.Pid)
|
log.Printf("Just ran subprocess %d, exiting\n", cmd.Process.Pid)
|
||||||
|
@ -93,7 +93,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
NSLog("pid: \(pid)")
|
NSLog("pid: \(pid)")
|
||||||
let serverProcess = Process()
|
let serverProcess = Process()
|
||||||
serverProcess.currentDirectoryPath = cwdUrl.path
|
serverProcess.currentDirectoryPath = cwdUrl.path
|
||||||
serverProcess.arguments = ["-monitorpid", "\(pid)", "-port", "\(serverPort)", "-single-user", sessionToken]
|
serverProcess.arguments = ["-monitorpid", "\(pid)", "-port", "\(serverPort)", "-single-user"]
|
||||||
|
serverProcess.environment = ["FOCALBOARD_SINGLE_USER_TOKEN": sessionToken]
|
||||||
serverProcess.launchPath = executablePath
|
serverProcess.launchPath = executablePath
|
||||||
serverProcess.launch()
|
serverProcess.launch()
|
||||||
self.serverProcess = serverProcess
|
self.serverProcess = serverProcess
|
||||||
|
@ -63,12 +63,22 @@ func main() {
|
|||||||
// Command line args
|
// Command line args
|
||||||
pMonitorPid := flag.Int("monitorpid", -1, "a process ID")
|
pMonitorPid := flag.Int("monitorpid", -1, "a process ID")
|
||||||
pPort := flag.Int("port", config.Port, "the port number")
|
pPort := flag.Int("port", config.Port, "the port number")
|
||||||
pSingleUserToken := flag.String("single-user", "", "single user token")
|
pSingleUser := flag.Bool("single-user", false, "single user mode")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
singleUser := false
|
||||||
|
if pSingleUser != nil {
|
||||||
|
singleUser = *pSingleUser
|
||||||
|
}
|
||||||
|
|
||||||
singleUserToken := ""
|
singleUserToken := ""
|
||||||
if pSingleUserToken != nil {
|
if singleUser {
|
||||||
singleUserToken = *pSingleUserToken
|
singleUserToken = os.Getenv("FOCALBOARD_SINGLE_USER_TOKEN")
|
||||||
|
if len(singleUserToken) < 1 {
|
||||||
|
log.Fatal("The FOCALBOARD_SINGLE_USER_TOKEN environment variable must be set for single user mode ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("Single user mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
if pMonitorPid != nil && *pMonitorPid > 0 {
|
if pMonitorPid != nil && *pMonitorPid > 0 {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"check": "eslint --ext .tsx,.ts . --quiet --cache",
|
"check": "eslint --ext .tsx,.ts . --quiet --cache",
|
||||||
"fix": "eslint --ext .tsx,.ts . --quiet --fix --cache",
|
"fix": "eslint --ext .tsx,.ts . --quiet --fix --cache",
|
||||||
"i18n-extract": "formatjs extract src/**/*.tsx src/**/*.ts --out-file i18n/tmp.json; formatjs compile i18n/tmp.json --out-file i18n/en.json; rm i18n/tmp.json",
|
"i18n-extract": "formatjs extract src/**/*.tsx src/**/*.ts --out-file i18n/tmp.json; formatjs compile i18n/tmp.json --out-file i18n/en.json; rm i18n/tmp.json",
|
||||||
"runserver-test": "cd cypress && ../../bin/focalboard-server -single-user TESTTOKEN",
|
"runserver-test": "cd cypress && FOCALBOARD_SINGLE_USER_TOKEN=TESTTOKEN ../../bin/focalboard-server -single-user",
|
||||||
"cypress:ci": "start-server-and-test runserver-test http://localhost:8088 cypress:run",
|
"cypress:ci": "start-server-and-test runserver-test http://localhost:8088 cypress:run",
|
||||||
"cypress:run": "cypress run",
|
"cypress:run": "cypress run",
|
||||||
"cypress:run:chrome": "cypress run --browser chrome",
|
"cypress:run:chrome": "cypress run --browser chrome",
|
||||||
|
@ -16,12 +16,13 @@ import (
|
|||||||
var sessionToken string = "su-" + uuid.New().String()
|
var sessionToken string = "su-" + uuid.New().String()
|
||||||
|
|
||||||
func runServer(ctx context.Context) *exec.Cmd {
|
func runServer(ctx context.Context) *exec.Cmd {
|
||||||
// cmd := exec.CommandContext(ctx, "focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
|
// cmd := exec.CommandContext(ctx, "focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user")
|
||||||
cmd := exec.CommandContext(ctx, "focalboard-server.exe", "-single-user", sessionToken)
|
cmd := exec.CommandContext(ctx, "focalboard-server.exe", "-single-user")
|
||||||
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10))
|
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10))
|
||||||
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe")
|
// cmd := exec.CommandContext(ctx, "cmd.exe", "/C", "start", "./bin/focalboard-server.exe")
|
||||||
|
|
||||||
// cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
// cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||||
|
cmd.Env = []string{fmt.Sprintf("FOCALBOARD_SINGLE_USER_TOKEN=%s", sessionToken)}
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
go func() {
|
go func() {
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
Reference in New Issue
Block a user