You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setting.go 39 kB

11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
11 years ago
11 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2017 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package setting
  6. import (
  7. "encoding/base64"
  8. "net"
  9. "net/url"
  10. "os"
  11. "os/exec"
  12. "path"
  13. "path/filepath"
  14. "regexp"
  15. "runtime"
  16. "strconv"
  17. "strings"
  18. "time"
  19. "code.gitea.io/git"
  20. "code.gitea.io/gitea/modules/generate"
  21. "code.gitea.io/gitea/modules/log"
  22. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  23. "code.gitea.io/gitea/modules/user"
  24. "github.com/Unknwon/com"
  25. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  26. _ "github.com/go-macaron/cache/redis"
  27. _ "github.com/go-macaron/session/couchbase" // couchbase plugin for session store
  28. _ "github.com/go-macaron/session/memcache" // memcache plugin for session store
  29. _ "github.com/go-macaron/session/mysql" // mysql plugin for session store
  30. _ "github.com/go-macaron/session/nodb" // nodb plugin for session store
  31. _ "github.com/go-macaron/session/postgres" // postgres plugin for session store
  32. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  33. shellquote "github.com/kballard/go-shellquote"
  34. version "github.com/mcuadros/go-version"
  35. ini "gopkg.in/ini.v1"
  36. "strk.kbt.io/projects/go/libravatar"
  37. )
  38. // Scheme describes protocol types
  39. type Scheme string
  40. // enumerates all the scheme types
  41. const (
  42. HTTP Scheme = "http"
  43. HTTPS Scheme = "https"
  44. FCGI Scheme = "fcgi"
  45. UnixSocket Scheme = "unix"
  46. )
  47. // LandingPage describes the default page
  48. type LandingPage string
  49. // enumerates all the landing page types
  50. const (
  51. LandingPageHome LandingPage = "/"
  52. LandingPageExplore LandingPage = "/explore"
  53. LandingPageOrganizations LandingPage = "/explore/organizations"
  54. )
  55. // MarkupParser defines the external parser configured in ini
  56. type MarkupParser struct {
  57. Enabled bool
  58. MarkupName string
  59. Command string
  60. FileExtensions []string
  61. IsInputFile bool
  62. }
  63. // enumerates all the policy repository creating
  64. const (
  65. RepoCreatingLastUserVisibility = "last"
  66. RepoCreatingPrivate = "private"
  67. RepoCreatingPublic = "public"
  68. )
  69. // enumerates all the types of captchas
  70. const (
  71. ImageCaptcha = "image"
  72. ReCaptcha = "recaptcha"
  73. )
  74. // settings
  75. var (
  76. // AppVer settings
  77. AppVer string
  78. AppBuiltWith string
  79. AppName string
  80. AppURL string
  81. AppSubURL string
  82. AppSubURLDepth int // Number of slashes
  83. AppPath string
  84. AppDataPath string
  85. AppWorkPath string
  86. // Server settings
  87. Protocol Scheme
  88. Domain string
  89. HTTPAddr string
  90. HTTPPort string
  91. LocalURL string
  92. RedirectOtherPort bool
  93. PortToRedirect string
  94. OfflineMode bool
  95. DisableRouterLog bool
  96. CertFile string
  97. KeyFile string
  98. StaticRootPath string
  99. EnableGzip bool
  100. LandingPageURL LandingPage
  101. UnixSocketPermission uint32
  102. EnablePprof bool
  103. PprofDataPath string
  104. EnableLetsEncrypt bool
  105. LetsEncryptTOS bool
  106. LetsEncryptDirectory string
  107. LetsEncryptEmail string
  108. SSH = struct {
  109. Disabled bool `ini:"DISABLE_SSH"`
  110. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  111. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  112. Domain string `ini:"SSH_DOMAIN"`
  113. Port int `ini:"SSH_PORT"`
  114. ListenHost string `ini:"SSH_LISTEN_HOST"`
  115. ListenPort int `ini:"SSH_LISTEN_PORT"`
  116. RootPath string `ini:"SSH_ROOT_PATH"`
  117. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  118. ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"`
  119. ServerMACs []string `ini:"SSH_SERVER_MACS"`
  120. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  121. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  122. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  123. MinimumKeySizeCheck bool `ini:"-"`
  124. MinimumKeySizes map[string]int `ini:"-"`
  125. CreateAuthorizedKeysFile bool `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
  126. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  127. }{
  128. Disabled: false,
  129. StartBuiltinServer: false,
  130. Domain: "",
  131. Port: 22,
  132. ServerCiphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
  133. ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
  134. ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
  135. KeygenPath: "ssh-keygen",
  136. }
  137. LFS struct {
  138. StartServer bool `ini:"LFS_START_SERVER"`
  139. ContentPath string `ini:"LFS_CONTENT_PATH"`
  140. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  141. JWTSecretBytes []byte `ini:"-"`
  142. HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
  143. }
  144. // Security settings
  145. InstallLock bool
  146. SecretKey string
  147. LogInRememberDays int
  148. CookieUserName string
  149. CookieRememberName string
  150. ReverseProxyAuthUser string
  151. ReverseProxyAuthEmail string
  152. MinPasswordLength int
  153. ImportLocalPaths bool
  154. DisableGitHooks bool
  155. // Database settings
  156. UseSQLite3 bool
  157. UseMySQL bool
  158. UseMSSQL bool
  159. UsePostgreSQL bool
  160. UseTiDB bool
  161. LogSQL bool
  162. DBConnectRetries int
  163. DBConnectBackoff time.Duration
  164. // Indexer settings
  165. Indexer struct {
  166. IssuePath string
  167. RepoIndexerEnabled bool
  168. RepoPath string
  169. UpdateQueueLength int
  170. MaxIndexerFileSize int64
  171. }
  172. // Repository settings
  173. Repository = struct {
  174. AnsiCharset string
  175. ForcePrivate bool
  176. DefaultPrivate string
  177. MaxCreationLimit int
  178. MirrorQueueLength int
  179. PullRequestQueueLength int
  180. PreferredLicenses []string
  181. DisableHTTPGit bool
  182. AccessControlAllowOrigin string
  183. UseCompatSSHURI bool
  184. DefaultCloseIssuesViaCommitsInAnyBranch bool
  185. // Repository editor settings
  186. Editor struct {
  187. LineWrapExtensions []string
  188. PreviewableFileModes []string
  189. } `ini:"-"`
  190. // Repository upload settings
  191. Upload struct {
  192. Enabled bool
  193. TempPath string
  194. AllowedTypes []string `delim:"|"`
  195. FileMaxSize int64
  196. MaxFiles int
  197. } `ini:"-"`
  198. // Repository local settings
  199. Local struct {
  200. LocalCopyPath string
  201. LocalWikiPath string
  202. } `ini:"-"`
  203. // Pull request settings
  204. PullRequest struct {
  205. WorkInProgressPrefixes []string
  206. } `ini:"repository.pull-request"`
  207. // Issue Setting
  208. Issue struct {
  209. LockReasons []string
  210. } `ini:"repository.issue"`
  211. }{
  212. AnsiCharset: "",
  213. ForcePrivate: false,
  214. DefaultPrivate: RepoCreatingLastUserVisibility,
  215. MaxCreationLimit: -1,
  216. MirrorQueueLength: 1000,
  217. PullRequestQueueLength: 1000,
  218. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  219. DisableHTTPGit: false,
  220. AccessControlAllowOrigin: "",
  221. UseCompatSSHURI: false,
  222. DefaultCloseIssuesViaCommitsInAnyBranch: false,
  223. // Repository editor settings
  224. Editor: struct {
  225. LineWrapExtensions []string
  226. PreviewableFileModes []string
  227. }{
  228. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  229. PreviewableFileModes: []string{"markdown"},
  230. },
  231. // Repository upload settings
  232. Upload: struct {
  233. Enabled bool
  234. TempPath string
  235. AllowedTypes []string `delim:"|"`
  236. FileMaxSize int64
  237. MaxFiles int
  238. }{
  239. Enabled: true,
  240. TempPath: "data/tmp/uploads",
  241. AllowedTypes: []string{},
  242. FileMaxSize: 3,
  243. MaxFiles: 5,
  244. },
  245. // Repository local settings
  246. Local: struct {
  247. LocalCopyPath string
  248. LocalWikiPath string
  249. }{
  250. LocalCopyPath: "tmp/local-repo",
  251. LocalWikiPath: "tmp/local-wiki",
  252. },
  253. // Pull request settings
  254. PullRequest: struct {
  255. WorkInProgressPrefixes []string
  256. }{
  257. WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
  258. },
  259. // Issue settings
  260. Issue: struct {
  261. LockReasons []string
  262. }{
  263. LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","),
  264. },
  265. }
  266. RepoRootPath string
  267. ScriptType = "bash"
  268. // UI settings
  269. UI = struct {
  270. ExplorePagingNum int
  271. IssuePagingNum int
  272. RepoSearchPagingNum int
  273. FeedMaxCommitNum int
  274. GraphMaxCommitNum int
  275. CodeCommentLines int
  276. ReactionMaxUserNum int
  277. ThemeColorMetaTag string
  278. MaxDisplayFileSize int64
  279. ShowUserEmail bool
  280. DefaultTheme string
  281. Themes []string
  282. Admin struct {
  283. UserPagingNum int
  284. RepoPagingNum int
  285. NoticePagingNum int
  286. OrgPagingNum int
  287. } `ini:"ui.admin"`
  288. User struct {
  289. RepoPagingNum int
  290. } `ini:"ui.user"`
  291. Meta struct {
  292. Author string
  293. Description string
  294. Keywords string
  295. } `ini:"ui.meta"`
  296. }{
  297. ExplorePagingNum: 20,
  298. IssuePagingNum: 10,
  299. RepoSearchPagingNum: 10,
  300. FeedMaxCommitNum: 5,
  301. GraphMaxCommitNum: 100,
  302. CodeCommentLines: 4,
  303. ReactionMaxUserNum: 10,
  304. ThemeColorMetaTag: `#6cc644`,
  305. MaxDisplayFileSize: 8388608,
  306. DefaultTheme: `gitea`,
  307. Themes: []string{`gitea`, `arc-green`},
  308. Admin: struct {
  309. UserPagingNum int
  310. RepoPagingNum int
  311. NoticePagingNum int
  312. OrgPagingNum int
  313. }{
  314. UserPagingNum: 50,
  315. RepoPagingNum: 50,
  316. NoticePagingNum: 25,
  317. OrgPagingNum: 50,
  318. },
  319. User: struct {
  320. RepoPagingNum int
  321. }{
  322. RepoPagingNum: 15,
  323. },
  324. Meta: struct {
  325. Author string
  326. Description string
  327. Keywords string
  328. }{
  329. Author: "Gitea - Git with a cup of tea",
  330. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  331. Keywords: "go,git,self-hosted,gitea",
  332. },
  333. }
  334. // Markdown settings
  335. Markdown = struct {
  336. EnableHardLineBreak bool
  337. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  338. FileExtensions []string
  339. }{
  340. EnableHardLineBreak: false,
  341. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  342. }
  343. // Admin settings
  344. Admin struct {
  345. DisableRegularOrgCreation bool
  346. }
  347. // Picture settings
  348. AvatarUploadPath string
  349. AvatarMaxWidth int
  350. AvatarMaxHeight int
  351. GravatarSource string
  352. GravatarSourceURL *url.URL
  353. DisableGravatar bool
  354. EnableFederatedAvatar bool
  355. LibravatarService *libravatar.Libravatar
  356. // Log settings
  357. LogLevel string
  358. LogRootPath string
  359. LogModes []string
  360. LogConfigs []string
  361. RedirectMacaronLog bool
  362. // Attachment settings
  363. AttachmentPath string
  364. AttachmentAllowedTypes string
  365. AttachmentMaxSize int64
  366. AttachmentMaxFiles int
  367. AttachmentEnabled bool
  368. // Time settings
  369. TimeFormat string
  370. CSRFCookieName = "_csrf"
  371. // Cron tasks
  372. Cron = struct {
  373. UpdateMirror struct {
  374. Enabled bool
  375. RunAtStart bool
  376. Schedule string
  377. } `ini:"cron.update_mirrors"`
  378. RepoHealthCheck struct {
  379. Enabled bool
  380. RunAtStart bool
  381. Schedule string
  382. Timeout time.Duration
  383. Args []string `delim:" "`
  384. } `ini:"cron.repo_health_check"`
  385. CheckRepoStats struct {
  386. Enabled bool
  387. RunAtStart bool
  388. Schedule string
  389. } `ini:"cron.check_repo_stats"`
  390. ArchiveCleanup struct {
  391. Enabled bool
  392. RunAtStart bool
  393. Schedule string
  394. OlderThan time.Duration
  395. } `ini:"cron.archive_cleanup"`
  396. SyncExternalUsers struct {
  397. Enabled bool
  398. RunAtStart bool
  399. Schedule string
  400. UpdateExisting bool
  401. } `ini:"cron.sync_external_users"`
  402. DeletedBranchesCleanup struct {
  403. Enabled bool
  404. RunAtStart bool
  405. Schedule string
  406. OlderThan time.Duration
  407. } `ini:"cron.deleted_branches_cleanup"`
  408. }{
  409. UpdateMirror: struct {
  410. Enabled bool
  411. RunAtStart bool
  412. Schedule string
  413. }{
  414. Enabled: true,
  415. RunAtStart: false,
  416. Schedule: "@every 10m",
  417. },
  418. RepoHealthCheck: struct {
  419. Enabled bool
  420. RunAtStart bool
  421. Schedule string
  422. Timeout time.Duration
  423. Args []string `delim:" "`
  424. }{
  425. Enabled: true,
  426. RunAtStart: false,
  427. Schedule: "@every 24h",
  428. Timeout: 60 * time.Second,
  429. Args: []string{},
  430. },
  431. CheckRepoStats: struct {
  432. Enabled bool
  433. RunAtStart bool
  434. Schedule string
  435. }{
  436. Enabled: true,
  437. RunAtStart: true,
  438. Schedule: "@every 24h",
  439. },
  440. ArchiveCleanup: struct {
  441. Enabled bool
  442. RunAtStart bool
  443. Schedule string
  444. OlderThan time.Duration
  445. }{
  446. Enabled: true,
  447. RunAtStart: true,
  448. Schedule: "@every 24h",
  449. OlderThan: 24 * time.Hour,
  450. },
  451. SyncExternalUsers: struct {
  452. Enabled bool
  453. RunAtStart bool
  454. Schedule string
  455. UpdateExisting bool
  456. }{
  457. Enabled: true,
  458. RunAtStart: false,
  459. Schedule: "@every 24h",
  460. UpdateExisting: true,
  461. },
  462. DeletedBranchesCleanup: struct {
  463. Enabled bool
  464. RunAtStart bool
  465. Schedule string
  466. OlderThan time.Duration
  467. }{
  468. Enabled: true,
  469. RunAtStart: true,
  470. Schedule: "@every 24h",
  471. OlderThan: 24 * time.Hour,
  472. },
  473. }
  474. // Git settings
  475. Git = struct {
  476. Version string `ini:"-"`
  477. DisableDiffHighlight bool
  478. MaxGitDiffLines int
  479. MaxGitDiffLineCharacters int
  480. MaxGitDiffFiles int
  481. GCArgs []string `delim:" "`
  482. Timeout struct {
  483. Default int
  484. Migrate int
  485. Mirror int
  486. Clone int
  487. Pull int
  488. GC int `ini:"GC"`
  489. } `ini:"git.timeout"`
  490. }{
  491. DisableDiffHighlight: false,
  492. MaxGitDiffLines: 1000,
  493. MaxGitDiffLineCharacters: 5000,
  494. MaxGitDiffFiles: 100,
  495. GCArgs: []string{},
  496. Timeout: struct {
  497. Default int
  498. Migrate int
  499. Mirror int
  500. Clone int
  501. Pull int
  502. GC int `ini:"GC"`
  503. }{
  504. Default: int(git.DefaultCommandExecutionTimeout / time.Second),
  505. Migrate: 600,
  506. Mirror: 300,
  507. Clone: 300,
  508. Pull: 300,
  509. GC: 60,
  510. },
  511. }
  512. // Mirror settings
  513. Mirror struct {
  514. DefaultInterval time.Duration
  515. MinInterval time.Duration
  516. }
  517. // API settings
  518. API = struct {
  519. EnableSwagger bool
  520. MaxResponseItems int
  521. DefaultPagingNum int
  522. DefaultGitTreesPerPage int
  523. }{
  524. EnableSwagger: true,
  525. MaxResponseItems: 50,
  526. DefaultPagingNum: 30,
  527. DefaultGitTreesPerPage: 1000,
  528. }
  529. U2F = struct {
  530. AppID string
  531. TrustedFacets []string
  532. }{}
  533. // Metrics settings
  534. Metrics = struct {
  535. Enabled bool
  536. Token string
  537. }{
  538. Enabled: false,
  539. Token: "",
  540. }
  541. // I18n settings
  542. Langs []string
  543. Names []string
  544. dateLangs map[string]string
  545. // Highlight settings are loaded in modules/template/highlight.go
  546. // Other settings
  547. ShowFooterBranding bool
  548. ShowFooterVersion bool
  549. ShowFooterTemplateLoadTime bool
  550. // Global setting objects
  551. Cfg *ini.File
  552. CustomPath string // Custom directory path
  553. CustomConf string
  554. CustomPID string
  555. ProdMode bool
  556. RunUser string
  557. IsWindows bool
  558. HasRobotsTxt bool
  559. InternalToken string // internal access token
  560. IterateBufferSize int
  561. ExternalMarkupParsers []MarkupParser
  562. // UILocation is the location on the UI, so that we can display the time on UI.
  563. // Currently only show the default time.Local, it could be added to app.ini after UI is ready
  564. UILocation = time.Local
  565. )
  566. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  567. func DateLang(lang string) string {
  568. name, ok := dateLangs[lang]
  569. if ok {
  570. return name
  571. }
  572. return "en"
  573. }
  574. func getAppPath() (string, error) {
  575. var appPath string
  576. var err error
  577. if IsWindows && filepath.IsAbs(os.Args[0]) {
  578. appPath = filepath.Clean(os.Args[0])
  579. } else {
  580. appPath, err = exec.LookPath(os.Args[0])
  581. }
  582. if err != nil {
  583. return "", err
  584. }
  585. appPath, err = filepath.Abs(appPath)
  586. if err != nil {
  587. return "", err
  588. }
  589. // Note: we don't use path.Dir here because it does not handle case
  590. // which path starts with two "/" in Windows: "//psf/Home/..."
  591. return strings.Replace(appPath, "\\", "/", -1), err
  592. }
  593. func getWorkPath(appPath string) string {
  594. workPath := ""
  595. giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
  596. if len(giteaWorkPath) > 0 {
  597. workPath = giteaWorkPath
  598. } else {
  599. i := strings.LastIndex(appPath, "/")
  600. if i == -1 {
  601. workPath = appPath
  602. } else {
  603. workPath = appPath[:i]
  604. }
  605. }
  606. return strings.Replace(workPath, "\\", "/", -1)
  607. }
  608. func init() {
  609. IsWindows = runtime.GOOS == "windows"
  610. log.NewLogger(0, "console", `{"level": 0}`)
  611. var err error
  612. if AppPath, err = getAppPath(); err != nil {
  613. log.Fatal(4, "Failed to get app path: %v", err)
  614. }
  615. AppWorkPath = getWorkPath(AppPath)
  616. }
  617. func forcePathSeparator(path string) {
  618. if strings.Contains(path, "\\") {
  619. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  620. }
  621. }
  622. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  623. // actual user that runs the app. The first return value is the actual user name.
  624. // This check is ignored under Windows since SSH remote login is not the main
  625. // method to login on Windows.
  626. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  627. if IsWindows {
  628. return "", true
  629. }
  630. currentUser := user.CurrentUsername()
  631. return currentUser, runUser == currentUser
  632. }
  633. func createPIDFile(pidPath string) {
  634. currentPid := os.Getpid()
  635. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  636. log.Fatal(4, "Failed to create PID folder: %v", err)
  637. }
  638. file, err := os.Create(pidPath)
  639. if err != nil {
  640. log.Fatal(4, "Failed to create PID file: %v", err)
  641. }
  642. defer file.Close()
  643. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  644. log.Fatal(4, "Failed to write PID information: %v", err)
  645. }
  646. }
  647. // CheckLFSVersion will check lfs version, if not satisfied, then disable it.
  648. func CheckLFSVersion() {
  649. if LFS.StartServer {
  650. //Disable LFS client hooks if installed for the current OS user
  651. //Needs at least git v2.1.2
  652. binVersion, err := git.BinVersion()
  653. if err != nil {
  654. log.Fatal(4, "Error retrieving git version: %v", err)
  655. }
  656. if !version.Compare(binVersion, "2.1.2", ">=") {
  657. LFS.StartServer = false
  658. log.Error(4, "LFS server support needs at least Git v2.1.2")
  659. } else {
  660. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  661. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  662. }
  663. }
  664. }
  665. // NewContext initializes configuration context.
  666. // NOTE: do not print any log except error.
  667. func NewContext() {
  668. Cfg = ini.Empty()
  669. CustomPath = os.Getenv("GITEA_CUSTOM")
  670. if len(CustomPath) == 0 {
  671. CustomPath = path.Join(AppWorkPath, "custom")
  672. } else if !filepath.IsAbs(CustomPath) {
  673. CustomPath = path.Join(AppWorkPath, CustomPath)
  674. }
  675. if len(CustomPID) > 0 {
  676. createPIDFile(CustomPID)
  677. }
  678. if len(CustomConf) == 0 {
  679. CustomConf = path.Join(CustomPath, "conf/app.ini")
  680. } else if !filepath.IsAbs(CustomConf) {
  681. CustomConf = path.Join(CustomPath, CustomConf)
  682. }
  683. if com.IsFile(CustomConf) {
  684. if err := Cfg.Append(CustomConf); err != nil {
  685. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  686. }
  687. } else {
  688. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  689. }
  690. Cfg.NameMapper = ini.AllCapsUnderscore
  691. homeDir, err := com.HomeDir()
  692. if err != nil {
  693. log.Fatal(4, "Failed to get home directory: %v", err)
  694. }
  695. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  696. LogLevel = getLogLevel("log", "LEVEL", "Info")
  697. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
  698. forcePathSeparator(LogRootPath)
  699. RedirectMacaronLog = Cfg.Section("log").Key("REDIRECT_MACARON_LOG").MustBool(false)
  700. sec := Cfg.Section("server")
  701. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  702. Protocol = HTTP
  703. if sec.Key("PROTOCOL").String() == "https" {
  704. Protocol = HTTPS
  705. CertFile = sec.Key("CERT_FILE").String()
  706. KeyFile = sec.Key("KEY_FILE").String()
  707. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  708. Protocol = FCGI
  709. } else if sec.Key("PROTOCOL").String() == "unix" {
  710. Protocol = UnixSocket
  711. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  712. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  713. if err != nil || UnixSocketPermissionParsed > 0777 {
  714. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  715. }
  716. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  717. }
  718. EnableLetsEncrypt = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
  719. LetsEncryptTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
  720. if !LetsEncryptTOS && EnableLetsEncrypt {
  721. log.Warn("Failed to enable Let's Encrypt due to Let's Encrypt TOS not being accepted")
  722. EnableLetsEncrypt = false
  723. }
  724. LetsEncryptDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
  725. LetsEncryptEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
  726. Domain = sec.Key("DOMAIN").MustString("localhost")
  727. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  728. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  729. defaultAppURL := string(Protocol) + "://" + Domain
  730. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  731. defaultAppURL += ":" + HTTPPort
  732. }
  733. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  734. AppURL = strings.TrimRight(AppURL, "/") + "/"
  735. // Check if has app suburl.
  736. url, err := url.Parse(AppURL)
  737. if err != nil {
  738. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  739. }
  740. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  741. // This value is empty if site does not have sub-url.
  742. AppSubURL = strings.TrimSuffix(url.Path, "/")
  743. AppSubURLDepth = strings.Count(AppSubURL, "/")
  744. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  745. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  746. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  747. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  748. Domain = urlHostname
  749. }
  750. var defaultLocalURL string
  751. switch Protocol {
  752. case UnixSocket:
  753. defaultLocalURL = "http://unix/"
  754. case FCGI:
  755. defaultLocalURL = AppURL
  756. default:
  757. defaultLocalURL = string(Protocol) + "://"
  758. if HTTPAddr == "0.0.0.0" {
  759. defaultLocalURL += "localhost"
  760. } else {
  761. defaultLocalURL += HTTPAddr
  762. }
  763. defaultLocalURL += ":" + HTTPPort + "/"
  764. }
  765. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  766. RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
  767. PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
  768. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  769. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  770. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
  771. AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
  772. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  773. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  774. PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
  775. if !filepath.IsAbs(PprofDataPath) {
  776. PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
  777. }
  778. switch sec.Key("LANDING_PAGE").MustString("home") {
  779. case "explore":
  780. LandingPageURL = LandingPageExplore
  781. case "organizations":
  782. LandingPageURL = LandingPageOrganizations
  783. default:
  784. LandingPageURL = LandingPageHome
  785. }
  786. if len(SSH.Domain) == 0 {
  787. SSH.Domain = Domain
  788. }
  789. SSH.RootPath = path.Join(homeDir, ".ssh")
  790. serverCiphers := sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  791. if len(serverCiphers) > 0 {
  792. SSH.ServerCiphers = serverCiphers
  793. }
  794. serverKeyExchanges := sec.Key("SSH_SERVER_KEY_EXCHANGES").Strings(",")
  795. if len(serverKeyExchanges) > 0 {
  796. SSH.ServerKeyExchanges = serverKeyExchanges
  797. }
  798. serverMACs := sec.Key("SSH_SERVER_MACS").Strings(",")
  799. if len(serverMACs) > 0 {
  800. SSH.ServerMACs = serverMACs
  801. }
  802. SSH.KeyTestPath = os.TempDir()
  803. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  804. log.Fatal(4, "Failed to map SSH settings: %v", err)
  805. }
  806. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  807. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  808. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  809. // When disable SSH, start builtin server value is ignored.
  810. if SSH.Disabled {
  811. SSH.StartBuiltinServer = false
  812. }
  813. if !SSH.Disabled && !SSH.StartBuiltinServer {
  814. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  815. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  816. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  817. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  818. }
  819. }
  820. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  821. SSH.MinimumKeySizes = map[string]int{}
  822. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  823. for _, key := range minimumKeySizes {
  824. if key.MustInt() != -1 {
  825. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  826. }
  827. }
  828. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  829. SSH.CreateAuthorizedKeysFile = sec.Key("SSH_CREATE_AUTHORIZED_KEYS_FILE").MustBool(true)
  830. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  831. sec = Cfg.Section("server")
  832. if err = sec.MapTo(&LFS); err != nil {
  833. log.Fatal(4, "Failed to map LFS settings: %v", err)
  834. }
  835. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  836. if !filepath.IsAbs(LFS.ContentPath) {
  837. LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
  838. }
  839. LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
  840. if LFS.StartServer {
  841. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  842. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  843. }
  844. LFS.JWTSecretBytes = make([]byte, 32)
  845. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  846. if err != nil || n != 32 {
  847. LFS.JWTSecretBase64, err = generate.NewLfsJwtSecret()
  848. if err != nil {
  849. log.Fatal(4, "Error generating JWT Secret for custom config: %v", err)
  850. return
  851. }
  852. // Save secret
  853. cfg := ini.Empty()
  854. if com.IsFile(CustomConf) {
  855. // Keeps custom settings if there is already something.
  856. if err := cfg.Append(CustomConf); err != nil {
  857. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  858. }
  859. }
  860. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  861. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  862. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  863. }
  864. if err := cfg.SaveTo(CustomConf); err != nil {
  865. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  866. return
  867. }
  868. }
  869. }
  870. sec = Cfg.Section("security")
  871. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  872. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  873. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  874. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  875. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  876. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  877. ReverseProxyAuthEmail = sec.Key("REVERSE_PROXY_AUTHENTICATION_EMAIL").MustString("X-WEBAUTH-EMAIL")
  878. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  879. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  880. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  881. InternalToken = sec.Key("INTERNAL_TOKEN").String()
  882. if len(InternalToken) == 0 {
  883. InternalToken, err = generate.NewInternalToken()
  884. if err != nil {
  885. log.Fatal(4, "Error generate internal token: %v", err)
  886. }
  887. // Save secret
  888. cfgSave := ini.Empty()
  889. if com.IsFile(CustomConf) {
  890. // Keeps custom settings if there is already something.
  891. if err := cfgSave.Append(CustomConf); err != nil {
  892. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  893. }
  894. }
  895. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(InternalToken)
  896. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  897. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  898. }
  899. if err := cfgSave.SaveTo(CustomConf); err != nil {
  900. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  901. }
  902. }
  903. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  904. LogSQL = Cfg.Section("database").Key("LOG_SQL").MustBool(true)
  905. DBConnectRetries = Cfg.Section("database").Key("DB_RETRIES").MustInt(10)
  906. DBConnectBackoff = Cfg.Section("database").Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
  907. sec = Cfg.Section("attachment")
  908. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  909. if !filepath.IsAbs(AttachmentPath) {
  910. AttachmentPath = path.Join(AppWorkPath, AttachmentPath)
  911. }
  912. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  913. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  914. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  915. AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
  916. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  917. TimeFormat = map[string]string{
  918. "ANSIC": time.ANSIC,
  919. "UnixDate": time.UnixDate,
  920. "RubyDate": time.RubyDate,
  921. "RFC822": time.RFC822,
  922. "RFC822Z": time.RFC822Z,
  923. "RFC850": time.RFC850,
  924. "RFC1123": time.RFC1123,
  925. "RFC1123Z": time.RFC1123Z,
  926. "RFC3339": time.RFC3339,
  927. "RFC3339Nano": time.RFC3339Nano,
  928. "Kitchen": time.Kitchen,
  929. "Stamp": time.Stamp,
  930. "StampMilli": time.StampMilli,
  931. "StampMicro": time.StampMicro,
  932. "StampNano": time.StampNano,
  933. }[TimeFormatKey]
  934. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  935. if len(TimeFormat) == 0 {
  936. TimeFormat = TimeFormatKey
  937. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  938. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  939. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  940. }
  941. log.Trace("Custom TimeFormat: %s", TimeFormat)
  942. }
  943. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  944. // Does not check run user when the install lock is off.
  945. if InstallLock {
  946. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  947. if !match {
  948. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  949. }
  950. }
  951. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  952. // Determine and create root git repository path.
  953. sec = Cfg.Section("repository")
  954. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  955. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  956. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  957. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  958. forcePathSeparator(RepoRootPath)
  959. if !filepath.IsAbs(RepoRootPath) {
  960. RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)
  961. } else {
  962. RepoRootPath = filepath.Clean(RepoRootPath)
  963. }
  964. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  965. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  966. log.Fatal(4, "Failed to map Repository settings: %v", err)
  967. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  968. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  969. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  970. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  971. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  972. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  973. } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil {
  974. log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err)
  975. }
  976. if !filepath.IsAbs(Repository.Upload.TempPath) {
  977. Repository.Upload.TempPath = path.Join(AppWorkPath, Repository.Upload.TempPath)
  978. }
  979. sec = Cfg.Section("picture")
  980. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  981. forcePathSeparator(AvatarUploadPath)
  982. if !filepath.IsAbs(AvatarUploadPath) {
  983. AvatarUploadPath = path.Join(AppWorkPath, AvatarUploadPath)
  984. }
  985. AvatarMaxWidth = sec.Key("AVATAR_MAX_WIDTH").MustInt(4096)
  986. AvatarMaxHeight = sec.Key("AVATAR_MAX_HEIGHT").MustInt(3072)
  987. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  988. case "duoshuo":
  989. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  990. case "gravatar":
  991. GravatarSource = "https://secure.gravatar.com/avatar/"
  992. case "libravatar":
  993. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  994. default:
  995. GravatarSource = source
  996. }
  997. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  998. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
  999. if OfflineMode {
  1000. DisableGravatar = true
  1001. EnableFederatedAvatar = false
  1002. }
  1003. if DisableGravatar {
  1004. EnableFederatedAvatar = false
  1005. }
  1006. if EnableFederatedAvatar || !DisableGravatar {
  1007. GravatarSourceURL, err = url.Parse(GravatarSource)
  1008. if err != nil {
  1009. log.Fatal(4, "Failed to parse Gravatar URL(%s): %v",
  1010. GravatarSource, err)
  1011. }
  1012. }
  1013. if EnableFederatedAvatar {
  1014. LibravatarService = libravatar.New()
  1015. if GravatarSourceURL.Scheme == "https" {
  1016. LibravatarService.SetUseHTTPS(true)
  1017. LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
  1018. } else {
  1019. LibravatarService.SetUseHTTPS(false)
  1020. LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
  1021. }
  1022. }
  1023. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  1024. log.Fatal(4, "Failed to map UI settings: %v", err)
  1025. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  1026. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  1027. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  1028. log.Fatal(4, "Fail to map Admin settings: %v", err)
  1029. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  1030. log.Fatal(4, "Failed to map Cron settings: %v", err)
  1031. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  1032. log.Fatal(4, "Failed to map Git settings: %v", err)
  1033. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  1034. log.Fatal(4, "Failed to map API settings: %v", err)
  1035. } else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
  1036. log.Fatal(4, "Failed to map Metrics settings: %v", err)
  1037. }
  1038. git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
  1039. sec = Cfg.Section("mirror")
  1040. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  1041. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  1042. if Mirror.MinInterval.Minutes() < 1 {
  1043. log.Warn("Mirror.MinInterval is too low")
  1044. Mirror.MinInterval = 1 * time.Minute
  1045. }
  1046. if Mirror.DefaultInterval < Mirror.MinInterval {
  1047. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  1048. Mirror.DefaultInterval = time.Hour * 8
  1049. }
  1050. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  1051. if len(Langs) == 0 {
  1052. Langs = []string{
  1053. "en-US", "zh-CN", "zh-HK", "zh-TW", "de-DE", "fr-FR", "nl-NL", "lv-LV",
  1054. "ru-RU", "uk-UA", "ja-JP", "es-ES", "pt-BR", "pl-PL", "bg-BG", "it-IT",
  1055. "fi-FI", "tr-TR", "cs-CZ", "sr-SP", "sv-SE", "ko-KR"}
  1056. }
  1057. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  1058. if len(Names) == 0 {
  1059. Names = []string{"English", "简体中文", "繁體中文(香港)", "繁體中文(台灣)", "Deutsch",
  1060. "français", "Nederlands", "latviešu", "русский", "Українська", "日本語",
  1061. "español", "português do Brasil", "polski", "български", "italiano",
  1062. "suomi", "Türkçe", "čeština", "српски", "svenska", "한국어"}
  1063. }
  1064. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  1065. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  1066. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  1067. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  1068. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  1069. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  1070. extensionReg := regexp.MustCompile(`\.\w`)
  1071. for _, sec := range Cfg.Section("markup").ChildSections() {
  1072. name := strings.TrimPrefix(sec.Name(), "markup.")
  1073. if name == "" {
  1074. log.Warn("name is empty, markup " + sec.Name() + "ignored")
  1075. continue
  1076. }
  1077. extensions := sec.Key("FILE_EXTENSIONS").Strings(",")
  1078. var exts = make([]string, 0, len(extensions))
  1079. for _, extension := range extensions {
  1080. if !extensionReg.MatchString(extension) {
  1081. log.Warn(sec.Name() + " file extension " + extension + " is invalid. Extension ignored")
  1082. } else {
  1083. exts = append(exts, extension)
  1084. }
  1085. }
  1086. if len(exts) == 0 {
  1087. log.Warn(sec.Name() + " file extension is empty, markup " + name + " ignored")
  1088. continue
  1089. }
  1090. command := sec.Key("RENDER_COMMAND").MustString("")
  1091. if command == "" {
  1092. log.Warn(" RENDER_COMMAND is empty, markup " + name + " ignored")
  1093. continue
  1094. }
  1095. ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
  1096. Enabled: sec.Key("ENABLED").MustBool(false),
  1097. MarkupName: name,
  1098. FileExtensions: exts,
  1099. Command: command,
  1100. IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
  1101. })
  1102. }
  1103. sec = Cfg.Section("U2F")
  1104. U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
  1105. U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
  1106. binVersion, err := git.BinVersion()
  1107. if err != nil {
  1108. log.Fatal(4, "Error retrieving git version: %v", err)
  1109. }
  1110. if version.Compare(binVersion, "2.9", ">=") {
  1111. // Explicitly disable credential helper, otherwise Git credentials might leak
  1112. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
  1113. }
  1114. }
  1115. // NewServices initializes the services
  1116. func NewServices() {
  1117. newService()
  1118. newLogService()
  1119. NewXORMLogService(false)
  1120. newCacheService()
  1121. newSessionService()
  1122. newMailService()
  1123. newRegisterMailService()
  1124. newNotifyMailService()
  1125. newWebhookService()
  1126. }