Adopt File type for trust logos and MCP

Trust GraphQL and MCP still exposed presigned URL strings for
trust-center logos while console and connect already serve stable
File.downloadUrl paths. Phase 1 migrates the seven public logo
fields on trust GraphQL and the trust-center file references on MCP
to the shared File type; trust GraphQL NDA stays on fileUrl for a
follow-up.

Trust resolvers load public files through filemanager and map them
with types.NewFile. The trust app Relay queries and components now
read logo.downloadUrl. MCP specification, resolvers, and helpers
are updated in sync, including NDA on MCP where callers already
have file access.

filemanager is split into focused files and its URL surface is
narrowed to GenerateFileURL(file) for stable app URLs and
GeneratePresignedURL for S3 redirects. GetPublicFile remains the
DB entry point when only a file ID is known.

Add trust and MCP e2e coverage for public logo download URLs.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-06-11 13:54:59 +02:00
parent e06f3e0520
commit eccef41767
60 changed files with 1004 additions and 400 deletions

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package mcp_v1
import (
"context"
"errors"
"fmt"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/server/api/mcp/v1/types"
)
func (r *Resolver) loadFile(
ctx context.Context,
scope *coredata.Scope,
fileID gid.GID,
) (*types.File, error) {
file, err := r.proboSvc.Files.Get(ctx, scope, fileID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, fmt.Errorf("file not found")
}
return nil, fmt.Errorf("cannot load file: %w", err)
}
return types.NewFile(file, r.fileManager), nil
}

View File

@@ -24,8 +24,10 @@ import (
"go.gearno.de/kit/log"
"go.probo.inc/probo/pkg/accessreview"
"go.probo.inc/probo/pkg/baseurl"
"go.probo.inc/probo/pkg/cookiebanner"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/filemanager"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/iam"
"go.probo.inc/probo/pkg/probo"
@@ -43,6 +45,8 @@ type Resolver struct {
cookieBanner *cookiebanner.Service
riskManagement *riskmanagement.Service
logger *log.Logger
fileManager *filemanager.Service
baseURL *baseurl.BaseURL
}
func markdownToProseMirrorJSON(markdown string) (string, error) {

View File

@@ -4910,19 +4910,31 @@ func (r *Resolver) GetTrustCenterTool(ctx context.Context, req *mcp.CallToolRequ
tc := types.NewTrustCenter(trustCenter)
logoURL, err := prb.TrustCenters.GenerateLogoURL(ctx, scope, trustCenter.ID, 1*time.Hour)
if err == nil {
tc.LogoFileURL = logoURL
if trustCenter.LogoFileID != nil {
logo, err := r.loadFile(ctx, scope, *trustCenter.LogoFileID)
if err != nil {
return nil, types.GetTrustCenterOutput{}, err
}
tc.Logo = logo
}
darkLogoURL, err := prb.TrustCenters.GenerateDarkLogoURL(ctx, scope, trustCenter.ID, 1*time.Hour)
if err == nil {
tc.DarkLogoFileURL = darkLogoURL
if trustCenter.DarkLogoFileID != nil {
darkLogo, err := r.loadFile(ctx, scope, *trustCenter.DarkLogoFileID)
if err != nil {
return nil, types.GetTrustCenterOutput{}, err
}
tc.DarkLogo = darkLogo
}
ndaFileURL, err := prb.TrustCenters.GenerateNDAFileURL(ctx, scope, trustCenter.ID, 15*time.Minute)
if err == nil {
tc.NdaFileURL = ndaFileURL
if trustCenter.NonDisclosureAgreementFileID != nil {
nda, err := r.loadFile(ctx, scope, *trustCenter.NonDisclosureAgreementFileID)
if err != nil {
return nil, types.GetTrustCenterOutput{}, err
}
tc.Nda = nda
}
return nil, types.GetTrustCenterOutput{TrustCenter: tc}, nil
@@ -4987,7 +4999,21 @@ func (r *Resolver) ListTrustCenterReferencesTool(ctx context.Context, req *mcp.C
return nil, types.ListTrustCenterReferencesOutput{}, fmt.Errorf("cannot list trust center references: %w", err)
}
return nil, types.NewListTrustCenterReferencesOutput(p), nil
refs := make([]*types.TrustCenterReference, 0, len(p.Data))
for _, reference := range p.Data {
ref := types.NewTrustCenterReference(reference)
logo, err := r.loadFile(ctx, scope, reference.LogoFileID)
if err != nil {
return nil, types.ListTrustCenterReferencesOutput{}, err
}
ref.Logo = logo
refs = append(refs, ref)
}
return nil, types.NewListTrustCenterReferencesOutput(refs, p), nil
}
// AddTrustCenterReferenceTool handles the addTrustCenterReference tool
@@ -5106,12 +5132,12 @@ func (r *Resolver) ListTrustCenterFilesTool(ctx context.Context, req *mcp.CallTo
files := make([]*types.TrustCenterFile, 0, len(p.Data))
for _, f := range p.Data {
fileURL, err := prb.TrustCenterFiles.GenerateFileURL(ctx, scope, f.ID, 1*time.Hour)
file, err := r.loadFile(ctx, scope, f.FileID)
if err != nil {
return nil, types.ListTrustCenterFilesOutput{}, fmt.Errorf("cannot generate file URL: %w", err)
return nil, types.ListTrustCenterFilesOutput{}, err
}
files = append(files, types.NewTrustCenterFile(f, fileURL))
files = append(files, types.NewTrustCenterFile(f, file))
}
return nil, types.NewListTrustCenterFilesOutput(files, p), nil

View File

@@ -8846,6 +8846,35 @@ components:
direction:
$ref: "#/components/schemas/OrderDirection"
File:
type: object
required:
- id
- mime_type
- file_name
- size
- download_url
- created_at
- updated_at
properties:
id:
$ref: "#/components/schemas/GID"
mime_type:
type: string
file_name:
type: string
size:
type: integer
format: int64
download_url:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
TrustCenter:
type: object
required:
@@ -8864,22 +8893,12 @@ components:
type: boolean
search_engine_indexing:
$ref: "#/components/schemas/SearchEngineIndexing"
logo_file_url:
type:
- string
- "null"
dark_logo_file_url:
type:
- string
- "null"
nda_file_name:
type:
- string
- "null"
nda_file_url:
type:
- string
- "null"
logo:
$ref: "#/components/schemas/File"
dark_logo:
$ref: "#/components/schemas/File"
nda:
$ref: "#/components/schemas/File"
created_at:
type: string
format: date-time
@@ -8908,10 +8927,8 @@ components:
type:
- string
- "null"
logo_url:
type:
- string
- "null"
logo:
$ref: "#/components/schemas/File"
rank:
type: integer
created_at:
@@ -8927,7 +8944,7 @@ components:
- id
- name
- category
- file_url
- file
- trust_center_visibility
- organization_id
- created_at
@@ -8939,8 +8956,8 @@ components:
type: string
category:
type: string
file_url:
type: string
file:
$ref: "#/components/schemas/File"
trust_center_visibility:
$ref: "#/components/schemas/TrustCenterVisibility"
organization_id:

View File

@@ -0,0 +1,32 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package types
import (
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/filemanager"
)
func NewFile(r *coredata.File, files *filemanager.Service) *File {
return &File{
ID: r.ID,
MimeType: r.MimeType,
FileName: r.FileName,
Size: int(r.FileSize),
DownloadURL: files.GenerateFileURL(r),
CreatedAt: r.CreatedAt,
UpdatedAt: r.UpdatedAt,
}
}

View File

@@ -42,12 +42,10 @@ func NewTrustCenterReference(r *coredata.TrustCenterReference) *TrustCenterRefer
}
}
func NewListTrustCenterReferencesOutput(p *page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField]) ListTrustCenterReferencesOutput {
refs := make([]*TrustCenterReference, 0, len(p.Data))
for _, r := range p.Data {
refs = append(refs, NewTrustCenterReference(r))
}
func NewListTrustCenterReferencesOutput(
refs []*TrustCenterReference,
p *page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField],
) ListTrustCenterReferencesOutput {
var nextCursor *page.CursorKey
if len(p.Data) > 0 {
@@ -61,13 +59,13 @@ func NewListTrustCenterReferencesOutput(p *page.Page[*coredata.TrustCenterRefere
}
}
func NewTrustCenterFile(f *coredata.TrustCenterFile, fileURL string) *TrustCenterFile {
func NewTrustCenterFile(f *coredata.TrustCenterFile, file *File) *TrustCenterFile {
return &TrustCenterFile{
ID: f.ID,
OrganizationID: f.OrganizationID,
Name: f.Name,
Category: f.Category,
FileURL: fileURL,
File: file,
TrustCenterVisibility: f.TrustCenterVisibility,
CreatedAt: f.CreatedAt,
UpdatedAt: f.UpdatedAt,

View File

@@ -22,7 +22,9 @@ import (
"go.gearno.de/kit/log"
mcpgenmcp "go.probo.inc/mcpgen/mcp"
"go.probo.inc/probo/pkg/accessreview"
"go.probo.inc/probo/pkg/baseurl"
"go.probo.inc/probo/pkg/cookiebanner"
"go.probo.inc/probo/pkg/filemanager"
"go.probo.inc/probo/pkg/iam"
"go.probo.inc/probo/pkg/probo"
"go.probo.inc/probo/pkg/riskmanagement"
@@ -41,6 +43,8 @@ func NewMux(
cookieBannerSvc *cookiebanner.Service,
riskManagementSvc *riskmanagement.Service,
tokenSecret string,
fileManagerSvc *filemanager.Service,
baseURL *baseurl.BaseURL,
) *chi.Mux {
logger = logger.Named("mcp.v1")
@@ -54,6 +58,8 @@ func NewMux(
cookieBanner: cookieBannerSvc,
riskManagement: riskManagementSvc,
logger: logger,
fileManager: fileManagerSvc,
baseURL: baseURL,
}
mcpServer := server.New(resolver, mcpgenmcp.WithRecoverFunc(mcputils.NewRecoverFunc(logger)))