Skip to content

Commit 59634fc

Browse files
committed
overridable upload limit
1 parent 448874e commit 59634fc

11 files changed

Lines changed: 340 additions & 180 deletions

File tree

config/config.go

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,33 @@ func ConfigFromFile(filePath string) (*ConfigDef, error) {
144144
LOG_QUERIES: dbConfig.LOG_QUERIES,
145145
},
146146
HttpServer: httpserver.HttpServerConfigDef{
147-
Bind: httpServerConfig.BIND,
148-
WriteTimeout: httpServerConfig.WRITE_TIMEOUT,
149-
ReadTimeout: httpServerConfig.READ_TIMEOUT,
150-
SessionKey: httpServerConfig.SESSION_KEY,
151-
RedisURIForSession: redisConfig.GetSessionRedisURI(),
152-
RedisURI: redisConfig.REDIS_URI,
153-
SiteName: httpServerConfig.SITE_NAME,
154-
SiteTitle: httpServerConfig.SITE_TITLE,
155-
ImageDomain: httpServerConfig.IMAGE_DOMAIN,
156-
DefaultURLFormat: defaultURLFormat,
157-
EnableSafeImageCheck: utils.IsStrTruthy(httpServerConfig.ENABLE_SAFE_IMAGE_CHECK),
158-
SafeImageCheckEndpoint: httpServerConfig.SAFE_IMAGE_CHECK_ENDPOINT,
159-
CaptchaProvider: captchaProvider,
160-
RecaptchaClientKey: httpServerConfig.RECAPTCHA_CLIENT_KEY,
161-
TurnstileSiteKey: httpServerConfig.TURNSTILE_SITE_KEY,
162-
RecaptchaServerKey: httpServerConfig.RECAPTCHA_SERVER_KEY,
163-
TurnstileSecretKey: httpServerConfig.TURNSTILE_SECRET_KEY,
164-
CustomCSS: httpServerConfig.CUSTOM_CSS,
165-
CustomJS: httpServerConfig.CUSTOM_JS,
166-
GoogleAnalyticsID: httpServerConfig.GOOGLE_ANALYTICS_ID,
167-
AllowUpload: utils.IsStrTruthy(httpServerConfig.ALLOW_UPLOAD),
168-
AllowNewUser: utils.IsStrTruthy(httpServerConfig.ALLOW_NEW_USER),
169-
ImageCacheMaxBytes: httpServerConfig.IMAGE_CACHE_MAX_BYTES,
170-
ImageCacheMaxFileBytes: httpServerConfig.IMAGE_CACHE_MAX_FILE_BYTES,
171-
ImageMaxUploadBytes: httpServerConfig.IMAGE_MAX_UPLOAD_BYTES,
172-
WebUIOrigins: httpserver.ParseOriginList(httpServerConfig.WEB_UI_ORIGINS),
147+
Bind: httpServerConfig.BIND,
148+
WriteTimeout: httpServerConfig.WRITE_TIMEOUT,
149+
ReadTimeout: httpServerConfig.READ_TIMEOUT,
150+
SessionKey: httpServerConfig.SESSION_KEY,
151+
RedisURIForSession: redisConfig.GetSessionRedisURI(),
152+
RedisURI: redisConfig.REDIS_URI,
153+
SiteName: httpServerConfig.SITE_NAME,
154+
SiteTitle: httpServerConfig.SITE_TITLE,
155+
ImageDomain: httpServerConfig.IMAGE_DOMAIN,
156+
DefaultURLFormat: defaultURLFormat,
157+
EnableSafeImageCheck: utils.IsStrTruthy(httpServerConfig.ENABLE_SAFE_IMAGE_CHECK),
158+
SafeImageCheckEndpoint: httpServerConfig.SAFE_IMAGE_CHECK_ENDPOINT,
159+
CaptchaProvider: captchaProvider,
160+
RecaptchaClientKey: httpServerConfig.RECAPTCHA_CLIENT_KEY,
161+
TurnstileSiteKey: httpServerConfig.TURNSTILE_SITE_KEY,
162+
RecaptchaServerKey: httpServerConfig.RECAPTCHA_SERVER_KEY,
163+
TurnstileSecretKey: httpServerConfig.TURNSTILE_SECRET_KEY,
164+
CustomCSS: httpServerConfig.CUSTOM_CSS,
165+
CustomJS: httpServerConfig.CUSTOM_JS,
166+
GoogleAnalyticsID: httpServerConfig.GOOGLE_ANALYTICS_ID,
167+
AllowUpload: utils.IsStrTruthy(httpServerConfig.ALLOW_UPLOAD),
168+
AllowNewUser: utils.IsStrTruthy(httpServerConfig.ALLOW_NEW_USER),
169+
ImageCacheMaxBytes: httpServerConfig.IMAGE_CACHE_MAX_BYTES,
170+
ImageCacheMaxFileBytes: httpServerConfig.IMAGE_CACHE_MAX_FILE_BYTES,
171+
ImageMaxUploadBytes: httpServerConfig.IMAGE_MAX_UPLOAD_BYTES,
172+
GuestImageMaxUploadBytes: httpServerConfig.GUEST_IMAGE_MAX_UPLOAD_BYTES,
173+
WebUIOrigins: httpserver.ParseOriginList(httpServerConfig.WEB_UI_ORIGINS),
173174
},
174175
Storage: storage.StorageConfigDef{
175176
StorageDefSource: storageDefSource,
@@ -297,6 +298,9 @@ func mergeConfigs(configs ...*ConfigDef) *ConfigDef {
297298
if config.HttpServer.ImageMaxUploadBytes > 0 {
298299
merged.HttpServer.ImageMaxUploadBytes = config.HttpServer.ImageMaxUploadBytes
299300
}
301+
if config.HttpServer.GuestImageMaxUploadBytes > 0 {
302+
merged.HttpServer.GuestImageMaxUploadBytes = config.HttpServer.GuestImageMaxUploadBytes
303+
}
300304
if len(config.HttpServer.WebUIOrigins) > 0 {
301305
merged.HttpServer.WebUIOrigins = config.HttpServer.WebUIOrigins
302306
}

config/config_file.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,31 @@ func (r *RedisConfigFileDef) GetCacheRedisURI() string {
3838
}
3939

4040
type HTTPServerConfigFileDef struct {
41-
BIND string `toml:"BIND" comment:"HTTP server bind address"`
42-
WRITE_TIMEOUT int `toml:"WRITE_TIMEOUT" comment:"HTTP server write timeout"`
43-
READ_TIMEOUT int `toml:"READ_TIMEOUT" comment:"HTTP server read timeout"`
44-
SESSION_KEY string `toml:"SESSION_KEY" comment:"Session key"`
45-
SITE_NAME string `toml:"SITE_NAME" comment:"Site name"`
46-
SITE_TITLE string `toml:"SITE_TITLE" comment:"Site title"`
47-
IMAGE_DOMAIN string `toml:"IMAGE_DOMAIN" comment:"Image domain"`
48-
DEFAULT_URL_FORMAT string `toml:"DEFAULT_URL_FORMAT" comment:"Default URL format. Choices are \n1. 'canonical' - Chooses best backend, and proxies content from that backend. \n2. 'direct' - A backend identifier is included in the URL and directly proxies that storage backend. \n3. 'backend_direct' - URL directly links to the backend (not supported yet)"`
49-
ENABLE_SAFE_IMAGE_CHECK string `toml:"ENABLE_SAFE_IMAGE_CHECK" comment:"Enable safe image check. 'true', '1' or 'yes' to enable"`
50-
SAFE_IMAGE_CHECK_ENDPOINT string `toml:"SAFE_IMAGE_CHECK_ENDPOINT" comment:"Safe image check endpoint. Used if ENABLE_SAFE_IMAGE_CHECK is true"`
51-
CAPTCHA_PROVIDER string `toml:"CAPTCHA_PROVIDER" comment:"Captcha provider. Choices are 'off', 'recaptcha', 'turnstile'"`
52-
RECAPTCHA_CLIENT_KEY string `toml:"RECAPTCHA_CLIENT_KEY" comment:"Recaptcha client key. Used if CAPTCHA_PROVIDER is 'recaptcha'"`
53-
TURNSTILE_SITE_KEY string `toml:"TURNSTILE_SITE_KEY" comment:"Turnstile site key. Used if CAPTCHA_PROVIDER is 'turnstile'"`
54-
RECAPTCHA_SERVER_KEY string `toml:"RECAPTCHA_SERVER_KEY" comment:"Recaptcha server key. Used if CAPTCHA_PROVIDER is 'recaptcha'"`
55-
TURNSTILE_SECRET_KEY string `toml:"TURNSTILE_SECRET_KEY" comment:"Turnstile secret key. Used if CAPTCHA_PROVIDER is 'turnstile'"`
56-
CUSTOM_CSS string `toml:"CUSTOM_CSS" comment:"Custom CSS"`
57-
CUSTOM_JS string `toml:"CUSTOM_JS" comment:"Custom JS"`
58-
GOOGLE_ANALYTICS_ID string `toml:"GOOGLE_ANALYTICS_ID" comment:"Google Analytics measurement ID (e.g. G-XXXXXXX). When set, injects gtag.js and exposes window.GAID."`
59-
ALLOW_UPLOAD string `toml:"ALLOW_UPLOAD" comment:"Allow uploading new images. 'true', '1' or 'yes' to enable"`
60-
ALLOW_NEW_USER string `toml:"ALLOW_NEW_USER" comment:"Allow new user creation. 'true', '1' or 'yes' to enable"`
61-
IMAGE_CACHE_MAX_BYTES int64 `toml:"IMAGE_CACHE_MAX_BYTES" comment:"Optional in-memory HTTP image response cache byte budget. Leave unset or 0 to disable. Useful when a tiny set of immutable image URLs receives most traffic and the app server proxies storage bytes."`
62-
IMAGE_CACHE_MAX_FILE_BYTES int64 `toml:"IMAGE_CACHE_MAX_FILE_BYTES" comment:"Optional maximum single image size for the HTTP image response cache. Defaults to IMAGE_CACHE_MAX_BYTES when unset."`
63-
IMAGE_MAX_UPLOAD_BYTES int64 `toml:"IMAGE_MAX_UPLOAD_BYTES" comment:"Maximum image upload size in bytes. Defaults to 10485760 (10 MB)."`
64-
WEB_UI_ORIGINS string `toml:"WEB_UI_ORIGINS" comment:"Comma-separated list of origins (scheme://host[:port]) allowed to make CORS requests to the image endpoints."`
41+
BIND string `toml:"BIND" comment:"HTTP server bind address"`
42+
WRITE_TIMEOUT int `toml:"WRITE_TIMEOUT" comment:"HTTP server write timeout"`
43+
READ_TIMEOUT int `toml:"READ_TIMEOUT" comment:"HTTP server read timeout"`
44+
SESSION_KEY string `toml:"SESSION_KEY" comment:"Session key"`
45+
SITE_NAME string `toml:"SITE_NAME" comment:"Site name"`
46+
SITE_TITLE string `toml:"SITE_TITLE" comment:"Site title"`
47+
IMAGE_DOMAIN string `toml:"IMAGE_DOMAIN" comment:"Image domain"`
48+
DEFAULT_URL_FORMAT string `toml:"DEFAULT_URL_FORMAT" comment:"Default URL format. Choices are \n1. 'canonical' - Chooses best backend, and proxies content from that backend. \n2. 'direct' - A backend identifier is included in the URL and directly proxies that storage backend. \n3. 'backend_direct' - URL directly links to the backend (not supported yet)"`
49+
ENABLE_SAFE_IMAGE_CHECK string `toml:"ENABLE_SAFE_IMAGE_CHECK" comment:"Enable safe image check. 'true', '1' or 'yes' to enable"`
50+
SAFE_IMAGE_CHECK_ENDPOINT string `toml:"SAFE_IMAGE_CHECK_ENDPOINT" comment:"Safe image check endpoint. Used if ENABLE_SAFE_IMAGE_CHECK is true"`
51+
CAPTCHA_PROVIDER string `toml:"CAPTCHA_PROVIDER" comment:"Captcha provider. Choices are 'off', 'recaptcha', 'turnstile'"`
52+
RECAPTCHA_CLIENT_KEY string `toml:"RECAPTCHA_CLIENT_KEY" comment:"Recaptcha client key. Used if CAPTCHA_PROVIDER is 'recaptcha'"`
53+
TURNSTILE_SITE_KEY string `toml:"TURNSTILE_SITE_KEY" comment:"Turnstile site key. Used if CAPTCHA_PROVIDER is 'turnstile'"`
54+
RECAPTCHA_SERVER_KEY string `toml:"RECAPTCHA_SERVER_KEY" comment:"Recaptcha server key. Used if CAPTCHA_PROVIDER is 'recaptcha'"`
55+
TURNSTILE_SECRET_KEY string `toml:"TURNSTILE_SECRET_KEY" comment:"Turnstile secret key. Used if CAPTCHA_PROVIDER is 'turnstile'"`
56+
CUSTOM_CSS string `toml:"CUSTOM_CSS" comment:"Custom CSS"`
57+
CUSTOM_JS string `toml:"CUSTOM_JS" comment:"Custom JS"`
58+
GOOGLE_ANALYTICS_ID string `toml:"GOOGLE_ANALYTICS_ID" comment:"Google Analytics measurement ID (e.g. G-XXXXXXX). When set, injects gtag.js and exposes window.GAID."`
59+
ALLOW_UPLOAD string `toml:"ALLOW_UPLOAD" comment:"Allow uploading new images. 'true', '1' or 'yes' to enable"`
60+
ALLOW_NEW_USER string `toml:"ALLOW_NEW_USER" comment:"Allow new user creation. 'true', '1' or 'yes' to enable"`
61+
IMAGE_CACHE_MAX_BYTES int64 `toml:"IMAGE_CACHE_MAX_BYTES" comment:"Optional in-memory HTTP image response cache byte budget. Leave unset or 0 to disable. Useful when a tiny set of immutable image URLs receives most traffic and the app server proxies storage bytes."`
62+
IMAGE_CACHE_MAX_FILE_BYTES int64 `toml:"IMAGE_CACHE_MAX_FILE_BYTES" comment:"Optional maximum single image size for the HTTP image response cache. Defaults to IMAGE_CACHE_MAX_BYTES when unset."`
63+
IMAGE_MAX_UPLOAD_BYTES int64 `toml:"IMAGE_MAX_UPLOAD_BYTES" comment:"Maximum image upload size in bytes. Defaults to 10485760 (10 MB)."`
64+
GUEST_IMAGE_MAX_UPLOAD_BYTES int64 `toml:"GUEST_IMAGE_MAX_UPLOAD_BYTES" comment:"Maximum image upload size for unauthenticated users in bytes. Defaults to IMAGE_MAX_UPLOAD_BYTES when unset or 0."`
65+
WEB_UI_ORIGINS string `toml:"WEB_UI_ORIGINS" comment:"Comma-separated list of origins (scheme://host[:port]) allowed to make CORS requests to the image endpoints."`
6566
}
6667

6768
type StorageBackendItem struct {

db/.gen/imgdd/public/model/organization_user_table.go

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/.gen/imgdd/public/table/organization_user_table.go

Lines changed: 21 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE organization_user_table
2+
DROP COLUMN upload_limit_bytes;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE organization_user_table
2+
ADD COLUMN upload_limit_bytes BIGINT NULL;

domainmodels/identity.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package domainmodels
22

33
type OrganizationUser struct {
4-
Id string
5-
Organization *Organization
6-
User *User
7-
Roles []*Role
4+
Id string
5+
Organization *Organization
6+
User *User
7+
Roles []*Role
8+
UploadLimitBytes *int64
89
}
910

1011
func (ou *OrganizationUser) IsSiteOwner() bool {

0 commit comments

Comments
 (0)