Compare commits

...

3 Commits

Author SHA1 Message Date
allanice001
12f2c5e1c5 feat: dynamically set swagger host, and some ui improvements on ssh page 2025-11-06 05:52:06 +00:00
public-glueops-renovatebot[bot]
7dc7d1a1f1 chore(pindigest): update golang to d2ede9f #patch (#239)
Co-authored-by: public-glueops-renovatebot[bot] <186083205+public-glueops-renovatebot[bot]@users.noreply.github.com>
2025-11-06 05:16:38 +00:00
allanice001
6a16eccce5 fix: relax csp 2025-11-06 05:07:53 +00:00
6 changed files with 42 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
################################# #################################
# Builder: Go + Node in one # Builder: Go + Node in one
################################# #################################
FROM golang:1.25.4-alpine AS builder FROM golang:1.25.4-alpine@sha256:d2ede9f3341a67413127cf5366bb25bbad9b0a66e8173cae3a900ab00e84861f AS builder
RUN apk add --no-cache \ RUN apk add --no-cache \
bash git ca-certificates tzdata \ bash git ca-certificates tzdata \

View File

@@ -49,7 +49,7 @@ func SecurityHeaders(next http.Handler) http.Handler {
"default-src 'self'", "default-src 'self'",
"base-uri 'self'", "base-uri 'self'",
"form-action 'self'", "form-action 'self'",
"script-src 'self'", "script-src 'self' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com", "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"img-src 'self' data: blob:", "img-src 'self' data: blob:",
"font-src 'self' data: https://fonts.gstatic.com", "font-src 'self' data: https://fonts.gstatic.com",

View File

@@ -28,6 +28,7 @@ type Config struct {
Env string Env string
Debug bool Debug bool
Swagger bool Swagger bool
SwaggerHost string
} }
var ( var (
@@ -52,6 +53,7 @@ func Load() (Config, error) {
v.SetDefault("env", "development") v.SetDefault("env", "development")
v.SetDefault("debug", false) v.SetDefault("debug", false)
v.SetDefault("swagger", false) v.SetDefault("swagger", false)
v.SetDefault("swagger.host", "localhost:8080")
// Env setup and binding // Env setup and binding
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
@@ -73,6 +75,7 @@ func Load() (Config, error) {
"env", "env",
"debug", "debug",
"swagger", "swagger",
"swagger.host",
} }
for _, k := range keys { for _, k := range keys {
_ = v.BindEnv(k) _ = v.BindEnv(k)
@@ -96,6 +99,7 @@ func Load() (Config, error) {
Env: v.GetString("env"), Env: v.GetString("env"),
Debug: v.GetBool("debug"), Debug: v.GetBool("debug"),
Swagger: v.GetBool("swagger"), Swagger: v.GetBool("swagger"),
SwaggerHost: v.GetString("swagger.host"),
} }
// Validate // Validate

View File

@@ -62,6 +62,9 @@ func ListPublicSshKeys(db *gorm.DB) http.HandlerFunc {
return return
} }
if out == nil {
out = []dto.SshResponse{}
}
utils.WriteJSON(w, http.StatusOK, out) utils.WriteJSON(w, http.StatusOK, out)
} }
} }

11
main.go
View File

@@ -1,6 +1,12 @@
package main package main
import "github.com/glueops/autoglue/cmd" import (
"os"
"github.com/glueops/autoglue/cmd"
"github.com/glueops/autoglue/docs"
"github.com/joho/godotenv"
)
// @title AutoGlue API // @title AutoGlue API
// @version 1.0 // @version 1.0
@@ -10,7 +16,6 @@ import "github.com/glueops/autoglue/cmd"
// @BasePath /api/v1 // @BasePath /api/v1
// @schemes http https // @schemes http https
// @host localhost:8080
// @securityDefinitions.apikey BearerAuth // @securityDefinitions.apikey BearerAuth
// @in header // @in header
@@ -33,5 +38,7 @@ import "github.com/glueops/autoglue/cmd"
// @description Org-level secret // @description Org-level secret
func main() { func main() {
_ = godotenv.Load()
docs.SwaggerInfo.Host = os.Getenv("SWAGGER_HOST")
cmd.Execute() cmd.Execute()
} }

View File

@@ -307,7 +307,7 @@ export const SshPage = () => {
<TableHeader> <TableHeader>
<TableRow> <TableRow>
<TableHead>Name</TableHead> <TableHead>Name</TableHead>
<TableHead className="min-w-[360px]">Public Key</TableHead> <TableHead>Public Key</TableHead>
<TableHead>Fingerprint</TableHead> <TableHead>Fingerprint</TableHead>
<TableHead>Created</TableHead> <TableHead>Created</TableHead>
<TableHead className="w-[160px] text-right">Actions</TableHead> <TableHead className="w-[160px] text-right">Actions</TableHead>
@@ -320,14 +320,12 @@ export const SshPage = () => {
return ( return (
<TableRow key={k.id}> <TableRow key={k.id}>
<TableCell className="font-medium">{k.name || "—"}</TableCell> <TableCell className="font-medium">{k.name || "—"}</TableCell>
<TableCell className="max-w-[560px] truncate"> <TableCell>
<div className="flex items-start gap-2"> <Tooltip>
<TooltipTrigger asChild>
<Badge variant="secondary" className="whitespace-nowrap"> <Badge variant="secondary" className="whitespace-nowrap">
{keyType} {keyType}
</Badge> </Badge>
<Tooltip>
<TooltipTrigger asChild>
<span className="font-mono text-xs">{truncated}</span>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent className="max-w-[70vw]"> <TooltipContent className="max-w-[70vw]">
<div className="max-w-full"> <div className="max-w-full">
@@ -335,7 +333,6 @@ export const SshPage = () => {
</div> </div>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
</div>
</TableCell> </TableCell>
<TableCell className="font-mono text-xs">{k.fingerprint}</TableCell> <TableCell className="font-mono text-xs">{k.fingerprint}</TableCell>
<TableCell> <TableCell>
@@ -352,14 +349,14 @@ export const SshPage = () => {
<TableCell className="space-x-2 text-right"> <TableCell className="space-x-2 text-right">
<Button <Button
size="sm" size="sm"
variant="ghost" variant="outline"
onClick={() => copy(k.public_key ?? "", "Public key copied")} onClick={() => copy(k.public_key ?? "", "Public key copied")}
> >
Copy Pub Copy Pub
</Button> </Button>
<Button <Button
size="sm" size="sm"
variant="ghost" variant="outline"
onClick={() => copy(k.fingerprint ?? "", "Fingerprint copied")} onClick={() => copy(k.fingerprint ?? "", "Fingerprint copied")}
> >
Copy FP Copy FP