mirror of
https://github.com/penpot/penpot.git
synced 2026-10-31 23:10:31 +00:00
* 🎉 Add OAuth support for remote MCP connections Add MCP-specific discovery, client registration, and approval endpoints. Exchange single-use authorization codes with PKCE for the fixed MCP user token, enabling MCP and creating the token on approval when needed. Use self-contained client IDs without new database tables or stored client records. Keep temporary authorization state in Redis/Valkey. Accept bearer credentials while preserving query-parameter connections. Enable OAuth through PENPOT_MCP_AUTH_URI in multi-user mode. Document the environment variable in the README and implementation details in Serena. Explain protocol and concurrency decisions in the Clojure code. Cover token provisioning, OAuth state, client registration, HTTP flows, and the approval page with tests. AI-assisted-by: gpt-6 * 🐛 Wait for devenv initialization before starting builds Docker reports a container as Running as soon as its main process starts, while the entrypoint may still be preparing the development environment. manage.sh used that status to launch tmux jobs, allowing frontend builds to race with ownership changes to /opt/rustup and Cargo setup. On a fresh container, rustup could fail with Permission denied before the frontend watcher started. Nginx would later serve the existing JavaScript, leaving source changes absent from the running app despite restarting devenv. Wait for nginx's local health endpoint before launching the jobs. Nginx starts after entrypoint setup, so its response confirms that setup has finished. Allow up to 120 seconds and report a timeout without starting the jobs if initialization does not complete. Validation: shell syntax and whitespace checks pass. AI-assisted-by: gpt-6 * ♻️ Share the login modal with MCP authorization Extract the viewer login modal and its styles into a shared auth component, retaining the viewer wrapper and its close behavior. Use the modal on the MCP approval page and preserve the pending request through login. Closing it clears the saved return URL and shows a cancellation message without further actions. Cover return URL handling and cancellation with frontend tests. AI-assisted-by: gpt-6 * ✨ Show client icons in MCP authorization Preserve HTTPS logo URLs from client registration and published metadata and show the icon beside the application name on the approval page. Ignore unusable URLs and hide failed images without blocking approval. Update the access description to refer to MCP connections established from Penpot. Cover logo metadata and approval responses in backend tests. AI-assisted-by: gpt-6 * 🐛 Follow the system theme when no preference is configured Default to the system theme in the shared resolver used by the app and plugins. Preserve explicit light and dark choices, including the legacy default value that means dark. Reuse the reactive theme hook in progress widgets and show the system preference in settings for accounts without a configured theme. Verify preference resolution with regression tests and browser checks. All 1,474 frontend tests pass. AI-assisted-by: gpt-6 * 🐛 Replace expired MCP tokens during OAuth approval Settings can give an MCP token an expiry date. OAuth approval reused the newest MCP token without checking it, so an expired token reached the client and never matched a plugin connection. Approval now treats an expired token as missing and creates a new one. Token exchange rejects a code whose token expired after approval with invalid_grant. AI-assisted-by: claude-opus-5-5 * 🐛 Log unexpected errors on MCP OAuth endpoints The OAuth routes sit outside the shared HTTP middleware, so the shared error handler never saw them, and their own handler turned unexpected failures into a 503 without logging anything. Failures in the session middleware of the approval endpoints had no handler at all. Unexpected failures now also go through the shared error handler for its logging, while clients still get an OAuth error body. The OAuth error handler also wraps the session middleware of the approval endpoints. AI-assisted-by: claude-opus-5-5 * 🔧 Add devenv script to run the MCP server with OAuth start-mcp-devenv-oauth starts the MCP server in multi-user mode with PENPOT_MCP_AUTH_URI derived from PENPOT_PUBLIC_URI, to test OAuth in the devenv. Agentic tooling still uses the single-user start-mcp-devenv. AI-assisted-by: claude-opus-5-5 * 🐛 Fix failing test case --------- Co-authored-by: alonso.torres <alonso.torres@kaleidos.net>
240 lines
8.1 KiB
Plaintext
240 lines
8.1 KiB
Plaintext
worker_processes auto;
|
|
pid /tmp/nginx.pid;
|
|
include /etc/nginx/overrides/main.d/*.conf;
|
|
|
|
events {
|
|
worker_connections 65535;
|
|
multi_accept on;
|
|
}
|
|
|
|
http {
|
|
client_body_temp_path /tmp/client_temp;
|
|
proxy_temp_path /tmp/proxy_temp_path;
|
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
|
scgi_temp_path /tmp/scgi_temp;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_requests 30;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
|
|
server_tokens off;
|
|
|
|
reset_timedout_connection on;
|
|
client_body_timeout 30s;
|
|
client_header_timeout 30s;
|
|
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
error_log /dev/stderr;
|
|
|
|
# Access log enriched with upstream diagnostics: what the backend
|
|
# answered (us), how long it took to connect to it (uct), how long it
|
|
# took to answer (urt) and which internal address served the request
|
|
# (ua). With proxy_pass on variables there is no upstream keepalive,
|
|
# so uct measures one real TCP connection per request.
|
|
log_format penpot_upstream '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
|
|
'us=$upstream_status uct=$upstream_connect_time '
|
|
'urt=$upstream_response_time ua=$upstream_addr';
|
|
access_log /dev/stdout penpot_upstream;
|
|
|
|
proxy_connect_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
proxy_read_timeout 300s;
|
|
send_timeout 300s;
|
|
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_static on;
|
|
gzip_comp_level 6;
|
|
gzip_buffers 16 8k;
|
|
gzip_http_version 1.1;
|
|
|
|
gzip_types text/plain text/css text/javascript application/javascript application/json application/transit+json image/svg+xml application/wasm;
|
|
|
|
proxy_buffer_size 16k;
|
|
proxy_busy_buffers_size 24k; # essentially, proxy_buffer_size + 2 small buffers of 4k
|
|
proxy_buffers 32 4k;
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
# Link preview crawlers; their requests for the application root
|
|
# are served with dynamic Open Graph metadata from the backend.
|
|
map $http_user_agent $penpot_link_preview_agent {
|
|
default 0;
|
|
"~*(slackbot|discordbot|twitterbot|facebookexternalhit|facebookcatalog|whatsapp|telegrambot|linkedinbot|skypeuripreview|pinterestbot|redditbot|embedly|iframely|mastodon|bluesky|applebot|googlebot|bingbot|bingpreview|duckduckbot|mattermost-bot|opengraph[.]xyz|twitter card validator)" 1;
|
|
}
|
|
|
|
proxy_cache_path /tmp/cache/ levels=2:2 keys_zone=penpot:20m;
|
|
proxy_cache_methods GET HEAD;
|
|
proxy_cache_valid any 48h;
|
|
proxy_cache_key "$host$request_uri";
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Scheme $scheme;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
include /etc/nginx/overrides/http.d/*.conf;
|
|
|
|
server {
|
|
listen 8080 default_server reuseport backlog=16384;
|
|
${PENPOT_IPV6_LISTEN_DIRECTIVE}
|
|
server_name _;
|
|
|
|
client_max_body_size $PENPOT_HTTP_SERVER_MAX_BODY_SIZE;
|
|
charset utf-8;
|
|
|
|
etag off;
|
|
proxy_hide_header X-Powered-By;
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
|
|
root /var/www/app/;
|
|
|
|
${PENPOT_PUBLIC_PATH_DIRECTIVES}
|
|
|
|
location @handle_redirect {
|
|
set $redirect_uri "$upstream_http_location";
|
|
set $redirect_host "$upstream_http_x_host";
|
|
set $redirect_cache_control "$upstream_http_cache_control";
|
|
set $real_mtype "$upstream_http_x_mtype";
|
|
|
|
proxy_buffering off;
|
|
|
|
proxy_set_header Host "$redirect_host";
|
|
proxy_set_header Authorization "";
|
|
proxy_hide_header etag;
|
|
proxy_hide_header x-amz-id-2;
|
|
proxy_hide_header x-amz-request-id;
|
|
proxy_hide_header x-amz-meta-server-side-encryption;
|
|
proxy_hide_header x-amz-server-side-encryption;
|
|
proxy_ssl_server_name on;
|
|
proxy_pass $redirect_uri;
|
|
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
add_header x-internal-redirect "$redirect_uri";
|
|
add_header x-cache-control "$redirect_cache_control";
|
|
add_header cache-control "$redirect_cache_control";
|
|
add_header content-type "$real_mtype";
|
|
}
|
|
|
|
location /assets {
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_pass $PENPOT_BACKEND_URI/assets;
|
|
recursive_error_pages on;
|
|
proxy_intercept_errors on;
|
|
error_page 301 302 307 = @handle_redirect;
|
|
|
|
include /etc/nginx/overrides/assets.d/*.conf;
|
|
}
|
|
|
|
location /internal/assets {
|
|
internal;
|
|
alias /opt/data/assets;
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
add_header x-internal-redirect "$upstream_http_x_accel_redirect";
|
|
}
|
|
|
|
location = /link-preview {
|
|
proxy_pass $PENPOT_BACKEND_URI/link-preview$is_args$args;
|
|
}
|
|
|
|
location /api/export {
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_pass $PENPOT_EXPORTER_URI;
|
|
}
|
|
|
|
location = /.well-known/oauth-authorization-server/api/mcp/oauth {
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_pass $PENPOT_BACKEND_URI$request_uri;
|
|
}
|
|
|
|
location /api {
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_pass $PENPOT_BACKEND_URI/api;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
location /plugins {
|
|
alias /var/www/app/plugins;
|
|
proxy_http_version 1.1;
|
|
}
|
|
|
|
location /readyz {
|
|
access_log off;
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_pass $PENPOT_BACKEND_URI$uri$is_args$args;
|
|
}
|
|
|
|
location /ws/notifications {
|
|
proxy_set_header Host $proxy_host;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_pass $PENPOT_BACKEND_URI/ws/notifications;
|
|
}
|
|
|
|
include /etc/nginx/overrides/server.d/*.conf;
|
|
|
|
location / {
|
|
include /etc/nginx/overrides/location.d/*.conf;
|
|
|
|
# Regenerated from the environment on every container start
|
|
# (see nginx-entrypoint.sh) while its URL is only versioned by
|
|
# the build, so a flags only restart leaves the URL untouched.
|
|
# Caching it like a build asset would keep returning users on
|
|
# the previous PENPOT_FLAGS for up to a week.
|
|
location = /js/config.js {
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
add_header Cache-Control "no-store, no-cache, max-age=0" always;
|
|
}
|
|
|
|
location ~* \.(js|css|jpg|png|svg|gif|ttf|woff|woff2|wasm|map)$ {
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
add_header Cache-Control "public, max-age=604800" always; # 7 days
|
|
}
|
|
|
|
location ~ ^/[^/]+/(.*)$ {
|
|
return 301 " ${PENPOT_PUBLIC_PATH}404";
|
|
}
|
|
|
|
if ($penpot_link_preview_agent) {
|
|
rewrite ^/$ /link-preview last;
|
|
}
|
|
|
|
include /etc/nginx/nginx-security-headers.conf;
|
|
add_header Cache-Control "no-store, no-cache, max-age=0" always;
|
|
try_files $uri /index.html$is_args$args /index.html =404;
|
|
|
|
}
|
|
}
|
|
|
|
# Dedicated health endpoint consumed by the nginx-prometheus-exporter
|
|
# sidecar (deployed by ops, scraping http://127.0.0.1:8082/stub_status).
|
|
# `listen 8082` binds every interface and sits out of the public server:
|
|
# a compose port mapping delivers traffic to the container address, never
|
|
# to loopback, so only the published port decides who gets in from
|
|
# outside the host. Counts client-side connections only; it says nothing
|
|
# about the upstream pools.
|
|
server {
|
|
listen 8082;
|
|
server_name _;
|
|
|
|
access_log off;
|
|
|
|
location = /stub_status {
|
|
stub_status;
|
|
}
|
|
}
|
|
}
|