You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(auth): add auth support in turso dev
* fix(auth): change output if flag is used.
* fix(auth): add better message
---------
Co-authored-by: Gabriel Guerra <guergabo@Gabriels-MacBook-Pro.local>
// Set the appropriate output and error streams for the server process
80
95
sqld.Stdout=os.Stdout
81
96
sqld.Stderr=os.Stderr
82
97
83
-
// Start the server process
98
+
// Start the server process.
84
99
err=sqld.Start()
85
100
iferr!=nil {
86
101
fmt.Fprint(os.Stderr, sqldNotFoundErr)
87
102
returnerr
88
103
}
104
+
105
+
// Check if the server is actually running.
106
+
maxAttempts:=3
107
+
fori:=0; i<maxAttempts; i++ {
108
+
_, err:=http.Get(conn)
109
+
iferr==nil {
110
+
break
111
+
}
112
+
ifi==maxAttempts-1 {
113
+
fmt.Fprintf(os.Stderr, "sqld not ready after %d health check attempts\n", maxAttempts)
114
+
returnerr
115
+
}
116
+
time.Sleep(500*time.Millisecond)
117
+
}
118
+
89
119
fmt.Printf("sqld listening on port %s.\n", internal.Emph(devPort))
90
120
91
121
fmt.Printf("Use the following URL to configure your libSQL client SDK for local development:\n\n %s\n\n",
92
122
internal.Emph(conn))
93
-
fmt.Printf("No auth token is required when sqld is running locally.\n\n")
94
-
123
+
ifauthJwtFile!="" {
124
+
fmt.Printf("Using auth token from file %s.\n\n", authJwtFile)
125
+
} else {
126
+
fmt.Printf("By default, no auth token is required when sqld is running locally. If you want to require authentication, use %s to specify a file containing the JWT key.\n\n", internal.Emph("--auth-jwt-key-file"))
cmd.Flags().StringVarP(&authJwtFile, "auth-jwt-key-file", "a", "", "Path to a file with a JWT decoding key used to authenticate clients in the Hrana and HTTP APIs. The key is either a PKCS#8-encoded Ed25519 public key in PEM, or just plain bytes of the Ed25519 public key in URL-safe base64.")
0 commit comments