Use stable files API URLs for vendor logo fields

CommonThirdParty.logoUrl and TrustCenterReference.logoUrl were
returning expiring S3 presigned URLs, which break if cached or
shared past their TTL.

Replace with stable /api/files/v1/{id} application URLs.
file.Service now generates these via baseurl; a new filesign
package owns presigning for the files/v1 HTTP handler that
does the internal redirect.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-06-03 10:21:02 +02:00
parent 383ea5a2d4
commit 6c072a2f7b
14 changed files with 115 additions and 116 deletions

View File

@@ -31,7 +31,7 @@ import (
"go.probo.inc/probo/pkg/connector/provider"
"go.probo.inc/probo/pkg/cookiebanner"
"go.probo.inc/probo/pkg/esign"
"go.probo.inc/probo/pkg/file"
"go.probo.inc/probo/pkg/filesign"
"go.probo.inc/probo/pkg/geoloc"
"go.probo.inc/probo/pkg/iam"
"go.probo.inc/probo/pkg/mailman"
@@ -55,7 +55,7 @@ type (
BaseURL *baseurl.BaseURL
AllowedOrigins []string
Probo *probo.Service
File *file.Service
FileSign *filesign.Service
IAM *iam.Service
Trust *trust.Service
ESign *esign.Service
@@ -207,7 +207,7 @@ func NewServer(cfg Config) (*Server, error) {
),
filesHandler: files_v1.NewMux(
cfg.Logger.Named("files.v1"),
cfg.File,
cfg.FileSign,
),
mcpHandler: mcp_v1.NewMux(
cfg.Logger.Named("mcp.v1"),

View File

@@ -7,7 +7,6 @@ package console_v1
import (
"context"
"time"
"go.gearno.de/kit/log"
"go.probo.inc/probo/pkg/probo"
@@ -26,7 +25,7 @@ func (r *commonThirdPartyResolver) LogoURL(ctx context.Context, obj *types.Commo
return nil, nil
}
logoURL, err := r.thirdParty.GenerateLogoURL(ctx, *obj.LogoFileID, 1*time.Hour)
logoURL, err := r.thirdParty.GenerateLogoURL(ctx, *obj.LogoFileID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot generate common third party logo URL", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -1183,7 +1183,7 @@ func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.T
return "", err
}
fileURL, err := r.probo.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour)
fileURL, err := r.probo.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot generate logo URL", log.Error(err))
return "", gqlutils.Internal(ctx)

View File

@@ -22,7 +22,7 @@ import (
"github.com/go-chi/chi/v5"
"go.gearno.de/kit/log"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/file"
"go.probo.inc/probo/pkg/filesign"
"go.probo.inc/probo/pkg/gid"
)
@@ -30,10 +30,10 @@ const presignedURLExpiry = 1 * time.Hour
type Handler struct {
logger *log.Logger
fileSvc *file.Service
fileSvc *filesign.Service
}
func NewMux(logger *log.Logger, fileSvc *file.Service) *chi.Mux {
func NewMux(logger *log.Logger, fileSvc *filesign.Service) *chi.Mux {
h := &Handler{
logger: logger,
fileSvc: fileSvc,
@@ -55,7 +55,7 @@ func (h *Handler) handleGetPublicFile(w http.ResponseWriter, r *http.Request) {
return
}
presignedURL, err := h.fileSvc.GetPublicFileURL(r.Context(), fileID, presignedURLExpiry)
presignedURL, err := h.fileSvc.GeneratePresignedFileURL(r.Context(), fileID, presignedURLExpiry)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
http.NotFound(w, r)

View File

@@ -975,7 +975,7 @@ func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.T
scope := coredata.NewScopeFromObjectID(obj.ID)
trustService := r.trust
logoURL, err := trustService.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour)
logoURL, err := trustService.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot generate logo URL", log.Error(err))
return "", gqlutils.Internal(ctx)