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 42 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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  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. "io"
  9. "io/ioutil"
  10. "net"
  11. "net/url"
  12. "os"
  13. "os/exec"
  14. "path"
  15. "path/filepath"
  16. "regexp"
  17. "runtime"
  18. "strconv"
  19. "strings"
  20. "time"
  21. "code.gitea.io/git"
  22. "code.gitea.io/gitea/modules/generate"
  23. "code.gitea.io/gitea/modules/log"
  24. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  25. "code.gitea.io/gitea/modules/user"
  26. "github.com/Unknwon/com"
  27. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  28. _ "github.com/go-macaron/cache/redis"
  29. _ "github.com/go-macaron/session/couchbase" // couchbase plugin for session store
  30. _ "github.com/go-macaron/session/memcache" // memcache plugin for session store
  31. _ "github.com/go-macaron/session/mysql" // mysql plugin for session store
  32. _ "github.com/go-macaron/session/nodb" // nodb plugin for session store
  33. _ "github.com/go-macaron/session/postgres" // postgres plugin for session store
  34. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  35. shellquote "github.com/kballard/go-shellquote"
  36. version "github.com/mcuadros/go-version"
  37. ini "gopkg.in/ini.v1"
  38. "strk.kbt.io/projects/go/libravatar"
  39. )
  40. // Scheme describes protocol types
  41. type Scheme string
  42. // enumerates all the scheme types
  43. const (
  44. HTTP Scheme = "http"
  45. HTTPS Scheme = "https"
  46. FCGI Scheme = "fcgi"
  47. UnixSocket Scheme = "unix"
  48. )
  49. // LandingPage describes the default page
  50. type LandingPage string
  51. // enumerates all the landing page types
  52. const (
  53. LandingPageHome LandingPage = "/"
  54. LandingPageExplore LandingPage = "/explore"
  55. LandingPageOrganizations LandingPage = "/explore/organizations"
  56. )
  57. // MarkupParser defines the external parser configured in ini
  58. type MarkupParser struct {
  59. Enabled bool
  60. MarkupName string
  61. Command string
  62. FileExtensions []string
  63. IsInputFile bool
  64. }
  65. // enumerates all the policy repository creating
  66. const (
  67. RepoCreatingLastUserVisibility = "last"
  68. RepoCreatingPrivate = "private"
  69. RepoCreatingPublic = "public"
  70. )
  71. // enumerates all the types of captchas
  72. const (
  73. ImageCaptcha = "image"
  74. ReCaptcha = "recaptcha"
  75. )
  76. // settings
  77. var (
  78. // AppVer settings
  79. AppVer string
  80. AppBuiltWith string
  81. AppName string
  82. AppURL string
  83. AppSubURL string
  84. AppSubURLDepth int // Number of slashes
  85. AppPath string
  86. AppDataPath string
  87. AppWorkPath string
  88. // Server settings
  89. Protocol Scheme
  90. Domain string
  91. HTTPAddr string
  92. HTTPPort string
  93. LocalURL string
  94. RedirectOtherPort bool
  95. PortToRedirect string
  96. OfflineMode bool
  97. DisableRouterLog bool
  98. CertFile string
  99. KeyFile string
  100. StaticRootPath string
  101. EnableGzip bool
  102. LandingPageURL LandingPage
  103. UnixSocketPermission uint32
  104. EnablePprof bool
  105. PprofDataPath string
  106. EnableLetsEncrypt bool
  107. LetsEncryptTOS bool
  108. LetsEncryptDirectory string
  109. LetsEncryptEmail string
  110. SSH = struct {
  111. Disabled bool `ini:"DISABLE_SSH"`
  112. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  113. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  114. Domain string `ini:"SSH_DOMAIN"`
  115. Port int `ini:"SSH_PORT"`
  116. ListenHost string `ini:"SSH_LISTEN_HOST"`
  117. ListenPort int `ini:"SSH_LISTEN_PORT"`
  118. RootPath string `ini:"SSH_ROOT_PATH"`
  119. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  120. ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"`
  121. ServerMACs []string `ini:"SSH_SERVER_MACS"`
  122. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  123. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  124. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  125. MinimumKeySizeCheck bool `ini:"-"`
  126. MinimumKeySizes map[string]int `ini:"-"`
  127. CreateAuthorizedKeysFile bool `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
  128. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  129. }{
  130. Disabled: false,
  131. StartBuiltinServer: false,
  132. Domain: "",
  133. Port: 22,
  134. ServerCiphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
  135. ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
  136. ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
  137. KeygenPath: "ssh-keygen",
  138. }
  139. LFS struct {
  140. StartServer bool `ini:"LFS_START_SERVER"`
  141. ContentPath string `ini:"LFS_CONTENT_PATH"`
  142. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  143. JWTSecretBytes []byte `ini:"-"`
  144. HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
  145. }
  146. // Security settings
  147. InstallLock bool
  148. SecretKey string
  149. LogInRememberDays int
  150. CookieUserName string
  151. CookieRememberName string
  152. ReverseProxyAuthUser string
  153. ReverseProxyAuthEmail string
  154. MinPasswordLength int
  155. ImportLocalPaths bool
  156. DisableGitHooks bool
  157. // Database settings
  158. UseSQLite3 bool
  159. UseMySQL bool
  160. UseMSSQL bool
  161. UsePostgreSQL bool
  162. UseTiDB bool
  163. LogSQL bool
  164. DBConnectRetries int
  165. DBConnectBackoff time.Duration
  166. // Repository settings
  167. Repository = struct {
  168. AnsiCharset string
  169. ForcePrivate bool
  170. DefaultPrivate string
  171. MaxCreationLimit int
  172. MirrorQueueLength int
  173. PullRequestQueueLength int
  174. PreferredLicenses []string
  175. DisableHTTPGit bool
  176. AccessControlAllowOrigin string
  177. UseCompatSSHURI bool
  178. DefaultCloseIssuesViaCommitsInAnyBranch bool
  179. // Repository editor settings
  180. Editor struct {
  181. LineWrapExtensions []string
  182. PreviewableFileModes []string
  183. } `ini:"-"`
  184. // Repository upload settings
  185. Upload struct {
  186. Enabled bool
  187. TempPath string
  188. AllowedTypes []string `delim:"|"`
  189. FileMaxSize int64
  190. MaxFiles int
  191. } `ini:"-"`
  192. // Repository local settings
  193. Local struct {
  194. LocalCopyPath string
  195. LocalWikiPath string
  196. } `ini:"-"`
  197. // Pull request settings
  198. PullRequest struct {
  199. WorkInProgressPrefixes []string
  200. } `ini:"repository.pull-request"`
  201. // Issue Setting
  202. Issue struct {
  203. LockReasons []string
  204. } `ini:"repository.issue"`
  205. }{
  206. AnsiCharset: "",
  207. ForcePrivate: false,
  208. DefaultPrivate: RepoCreatingLastUserVisibility,
  209. MaxCreationLimit: -1,
  210. MirrorQueueLength: 1000,
  211. PullRequestQueueLength: 1000,
  212. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  213. DisableHTTPGit: false,
  214. AccessControlAllowOrigin: "",
  215. UseCompatSSHURI: false,
  216. DefaultCloseIssuesViaCommitsInAnyBranch: false,
  217. // Repository editor settings
  218. Editor: struct {
  219. LineWrapExtensions []string
  220. PreviewableFileModes []string
  221. }{
  222. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  223. PreviewableFileModes: []string{"markdown"},
  224. },
  225. // Repository upload settings
  226. Upload: struct {
  227. Enabled bool
  228. TempPath string
  229. AllowedTypes []string `delim:"|"`
  230. FileMaxSize int64
  231. MaxFiles int
  232. }{
  233. Enabled: true,
  234. TempPath: "data/tmp/uploads",
  235. AllowedTypes: []string{},
  236. FileMaxSize: 3,
  237. MaxFiles: 5,
  238. },
  239. // Repository local settings
  240. Local: struct {
  241. LocalCopyPath string
  242. LocalWikiPath string
  243. }{
  244. LocalCopyPath: "tmp/local-repo",
  245. LocalWikiPath: "tmp/local-wiki",
  246. },
  247. // Pull request settings
  248. PullRequest: struct {
  249. WorkInProgressPrefixes []string
  250. }{
  251. WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
  252. },
  253. // Issue settings
  254. Issue: struct {
  255. LockReasons []string
  256. }{
  257. LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","),
  258. },
  259. }
  260. RepoRootPath string
  261. ScriptType = "bash"
  262. // UI settings
  263. UI = struct {
  264. ExplorePagingNum int
  265. IssuePagingNum int
  266. RepoSearchPagingNum int
  267. FeedMaxCommitNum int
  268. GraphMaxCommitNum int
  269. CodeCommentLines int
  270. ReactionMaxUserNum int
  271. ThemeColorMetaTag string
  272. MaxDisplayFileSize int64
  273. ShowUserEmail bool
  274. DefaultTheme string
  275. Themes []string
  276. Admin struct {
  277. UserPagingNum int
  278. RepoPagingNum int
  279. NoticePagingNum int
  280. OrgPagingNum int
  281. } `ini:"ui.admin"`
  282. User struct {
  283. RepoPagingNum int
  284. } `ini:"ui.user"`
  285. Meta struct {
  286. Author string
  287. Description string
  288. Keywords string
  289. } `ini:"ui.meta"`
  290. }{
  291. ExplorePagingNum: 20,
  292. IssuePagingNum: 10,
  293. RepoSearchPagingNum: 10,
  294. FeedMaxCommitNum: 5,
  295. GraphMaxCommitNum: 100,
  296. CodeCommentLines: 4,
  297. ReactionMaxUserNum: 10,
  298. ThemeColorMetaTag: `#6cc644`,
  299. MaxDisplayFileSize: 8388608,
  300. DefaultTheme: `gitea`,
  301. Themes: []string{`gitea`, `arc-green`},
  302. Admin: struct {
  303. UserPagingNum int
  304. RepoPagingNum int
  305. NoticePagingNum int
  306. OrgPagingNum int
  307. }{
  308. UserPagingNum: 50,
  309. RepoPagingNum: 50,
  310. NoticePagingNum: 25,
  311. OrgPagingNum: 50,
  312. },
  313. User: struct {
  314. RepoPagingNum int
  315. }{
  316. RepoPagingNum: 15,
  317. },
  318. Meta: struct {
  319. Author string
  320. Description string
  321. Keywords string
  322. }{
  323. Author: "Gitea - Git with a cup of tea",
  324. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  325. Keywords: "go,git,self-hosted,gitea",
  326. },
  327. }
  328. // Markdown settings
  329. Markdown = struct {
  330. EnableHardLineBreak bool
  331. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  332. FileExtensions []string
  333. }{
  334. EnableHardLineBreak: false,
  335. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  336. }
  337. // Admin settings
  338. Admin struct {
  339. DisableRegularOrgCreation bool
  340. }
  341. // Picture settings
  342. AvatarUploadPath string
  343. AvatarMaxWidth int
  344. AvatarMaxHeight int
  345. GravatarSource string
  346. GravatarSourceURL *url.URL
  347. DisableGravatar bool
  348. EnableFederatedAvatar bool
  349. LibravatarService *libravatar.Libravatar
  350. // Log settings
  351. LogLevel string
  352. LogRootPath string
  353. LogModes []string
  354. LogConfigs []string
  355. RedirectMacaronLog bool
  356. // Attachment settings
  357. AttachmentPath string
  358. AttachmentAllowedTypes string
  359. AttachmentMaxSize int64
  360. AttachmentMaxFiles int
  361. AttachmentEnabled bool
  362. // Time settings
  363. TimeFormat string
  364. CSRFCookieName = "_csrf"
  365. // Cron tasks
  366. Cron = struct {
  367. UpdateMirror struct {
  368. Enabled bool
  369. RunAtStart bool
  370. Schedule string
  371. } `ini:"cron.update_mirrors"`
  372. RepoHealthCheck struct {
  373. Enabled bool
  374. RunAtStart bool
  375. Schedule string
  376. Timeout time.Duration
  377. Args []string `delim:" "`
  378. } `ini:"cron.repo_health_check"`
  379. CheckRepoStats struct {
  380. Enabled bool
  381. RunAtStart bool
  382. Schedule string
  383. } `ini:"cron.check_repo_stats"`
  384. ArchiveCleanup struct {
  385. Enabled bool
  386. RunAtStart bool
  387. Schedule string
  388. OlderThan time.Duration
  389. } `ini:"cron.archive_cleanup"`
  390. SyncExternalUsers struct {
  391. Enabled bool
  392. RunAtStart bool
  393. Schedule string
  394. UpdateExisting bool
  395. } `ini:"cron.sync_external_users"`
  396. DeletedBranchesCleanup struct {
  397. Enabled bool
  398. RunAtStart bool
  399. Schedule string
  400. OlderThan time.Duration
  401. } `ini:"cron.deleted_branches_cleanup"`
  402. }{
  403. UpdateMirror: struct {
  404. Enabled bool
  405. RunAtStart bool
  406. Schedule string
  407. }{
  408. Enabled: true,
  409. RunAtStart: false,
  410. Schedule: "@every 10m",
  411. },
  412. RepoHealthCheck: struct {
  413. Enabled bool
  414. RunAtStart bool
  415. Schedule string
  416. Timeout time.Duration
  417. Args []string `delim:" "`
  418. }{
  419. Enabled: true,
  420. RunAtStart: false,
  421. Schedule: "@every 24h",
  422. Timeout: 60 * time.Second,
  423. Args: []string{},
  424. },
  425. CheckRepoStats: struct {
  426. Enabled bool
  427. RunAtStart bool
  428. Schedule string
  429. }{
  430. Enabled: true,
  431. RunAtStart: true,
  432. Schedule: "@every 24h",
  433. },
  434. ArchiveCleanup: struct {
  435. Enabled bool
  436. RunAtStart bool
  437. Schedule string
  438. OlderThan time.Duration
  439. }{
  440. Enabled: true,
  441. RunAtStart: true,
  442. Schedule: "@every 24h",
  443. OlderThan: 24 * time.Hour,
  444. },
  445. SyncExternalUsers: struct {
  446. Enabled bool
  447. RunAtStart bool
  448. Schedule string
  449. UpdateExisting bool
  450. }{
  451. Enabled: true,
  452. RunAtStart: false,
  453. Schedule: "@every 24h",
  454. UpdateExisting: true,
  455. },
  456. DeletedBranchesCleanup: struct {
  457. Enabled bool
  458. RunAtStart bool
  459. Schedule string
  460. OlderThan time.Duration
  461. }{
  462. Enabled: true,
  463. RunAtStart: true,
  464. Schedule: "@every 24h",
  465. OlderThan: 24 * time.Hour,
  466. },
  467. }
  468. // Git settings
  469. Git = struct {
  470. Version string `ini:"-"`
  471. DisableDiffHighlight bool
  472. MaxGitDiffLines int
  473. MaxGitDiffLineCharacters int
  474. MaxGitDiffFiles int
  475. GCArgs []string `delim:" "`
  476. Timeout struct {
  477. Default int
  478. Migrate int
  479. Mirror int
  480. Clone int
  481. Pull int
  482. GC int `ini:"GC"`
  483. } `ini:"git.timeout"`
  484. }{
  485. DisableDiffHighlight: false,
  486. MaxGitDiffLines: 1000,
  487. MaxGitDiffLineCharacters: 5000,
  488. MaxGitDiffFiles: 100,
  489. GCArgs: []string{},
  490. Timeout: struct {
  491. Default int
  492. Migrate int
  493. Mirror int
  494. Clone int
  495. Pull int
  496. GC int `ini:"GC"`
  497. }{
  498. Default: int(git.DefaultCommandExecutionTimeout / time.Second),
  499. Migrate: 600,
  500. Mirror: 300,
  501. Clone: 300,
  502. Pull: 300,
  503. GC: 60,
  504. },
  505. }
  506. // Mirror settings
  507. Mirror struct {
  508. DefaultInterval time.Duration
  509. MinInterval time.Duration
  510. }
  511. // API settings
  512. API = struct {
  513. EnableSwagger bool
  514. MaxResponseItems int
  515. DefaultPagingNum int
  516. DefaultGitTreesPerPage int
  517. }{
  518. EnableSwagger: true,
  519. MaxResponseItems: 50,
  520. DefaultPagingNum: 30,
  521. DefaultGitTreesPerPage: 1000,
  522. }
  523. OAuth2 = struct {
  524. Enable bool
  525. AccessTokenExpirationTime int64
  526. RefreshTokenExpirationTime int64
  527. JWTSecretBytes []byte `ini:"-"`
  528. JWTSecretBase64 string `ini:"JWT_SECRET"`
  529. }{
  530. Enable: true,
  531. AccessTokenExpirationTime: 3600,
  532. RefreshTokenExpirationTime: 730,
  533. }
  534. U2F = struct {
  535. AppID string
  536. TrustedFacets []string
  537. }{}
  538. // Metrics settings
  539. Metrics = struct {
  540. Enabled bool
  541. Token string
  542. }{
  543. Enabled: false,
  544. Token: "",
  545. }
  546. // I18n settings
  547. Langs []string
  548. Names []string
  549. dateLangs map[string]string
  550. // Highlight settings are loaded in modules/template/highlight.go
  551. // Other settings
  552. ShowFooterBranding bool
  553. ShowFooterVersion bool
  554. ShowFooterTemplateLoadTime bool
  555. // Global setting objects
  556. Cfg *ini.File
  557. CustomPath string // Custom directory path
  558. CustomConf string
  559. CustomPID string
  560. ProdMode bool
  561. RunUser string
  562. IsWindows bool
  563. HasRobotsTxt bool
  564. InternalToken string // internal access token
  565. IterateBufferSize int
  566. ExternalMarkupParsers []MarkupParser
  567. // UILocation is the location on the UI, so that we can display the time on UI.
  568. // Currently only show the default time.Local, it could be added to app.ini after UI is ready
  569. UILocation = time.Local
  570. )
  571. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  572. func DateLang(lang string) string {
  573. name, ok := dateLangs[lang]
  574. if ok {
  575. return name
  576. }
  577. return "en"
  578. }
  579. func getAppPath() (string, error) {
  580. var appPath string
  581. var err error
  582. if IsWindows && filepath.IsAbs(os.Args[0]) {
  583. appPath = filepath.Clean(os.Args[0])
  584. } else {
  585. appPath, err = exec.LookPath(os.Args[0])
  586. }
  587. if err != nil {
  588. return "", err
  589. }
  590. appPath, err = filepath.Abs(appPath)
  591. if err != nil {
  592. return "", err
  593. }
  594. // Note: we don't use path.Dir here because it does not handle case
  595. // which path starts with two "/" in Windows: "//psf/Home/..."
  596. return strings.Replace(appPath, "\\", "/", -1), err
  597. }
  598. func getWorkPath(appPath string) string {
  599. workPath := ""
  600. giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
  601. if len(giteaWorkPath) > 0 {
  602. workPath = giteaWorkPath
  603. } else {
  604. i := strings.LastIndex(appPath, "/")
  605. if i == -1 {
  606. workPath = appPath
  607. } else {
  608. workPath = appPath[:i]
  609. }
  610. }
  611. return strings.Replace(workPath, "\\", "/", -1)
  612. }
  613. func init() {
  614. IsWindows = runtime.GOOS == "windows"
  615. log.NewLogger(0, "console", `{"level": 0}`)
  616. var err error
  617. if AppPath, err = getAppPath(); err != nil {
  618. log.Fatal(4, "Failed to get app path: %v", err)
  619. }
  620. AppWorkPath = getWorkPath(AppPath)
  621. }
  622. func forcePathSeparator(path string) {
  623. if strings.Contains(path, "\\") {
  624. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  625. }
  626. }
  627. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  628. // actual user that runs the app. The first return value is the actual user name.
  629. // This check is ignored under Windows since SSH remote login is not the main
  630. // method to login on Windows.
  631. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  632. if IsWindows {
  633. return "", true
  634. }
  635. currentUser := user.CurrentUsername()
  636. return currentUser, runUser == currentUser
  637. }
  638. func createPIDFile(pidPath string) {
  639. currentPid := os.Getpid()
  640. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  641. log.Fatal(4, "Failed to create PID folder: %v", err)
  642. }
  643. file, err := os.Create(pidPath)
  644. if err != nil {
  645. log.Fatal(4, "Failed to create PID file: %v", err)
  646. }
  647. defer file.Close()
  648. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  649. log.Fatal(4, "Failed to write PID information: %v", err)
  650. }
  651. }
  652. // CheckLFSVersion will check lfs version, if not satisfied, then disable it.
  653. func CheckLFSVersion() {
  654. if LFS.StartServer {
  655. //Disable LFS client hooks if installed for the current OS user
  656. //Needs at least git v2.1.2
  657. binVersion, err := git.BinVersion()
  658. if err != nil {
  659. log.Fatal(4, "Error retrieving git version: %v", err)
  660. }
  661. if !version.Compare(binVersion, "2.1.2", ">=") {
  662. LFS.StartServer = false
  663. log.Error(4, "LFS server support needs at least Git v2.1.2")
  664. } else {
  665. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  666. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  667. }
  668. }
  669. }
  670. // NewContext initializes configuration context.
  671. // NOTE: do not print any log except error.
  672. func NewContext() {
  673. Cfg = ini.Empty()
  674. CustomPath = os.Getenv("GITEA_CUSTOM")
  675. if len(CustomPath) == 0 {
  676. CustomPath = path.Join(AppWorkPath, "custom")
  677. } else if !filepath.IsAbs(CustomPath) {
  678. CustomPath = path.Join(AppWorkPath, CustomPath)
  679. }
  680. if len(CustomPID) > 0 {
  681. createPIDFile(CustomPID)
  682. }
  683. if len(CustomConf) == 0 {
  684. CustomConf = path.Join(CustomPath, "conf/app.ini")
  685. } else if !filepath.IsAbs(CustomConf) {
  686. CustomConf = path.Join(CustomPath, CustomConf)
  687. }
  688. if com.IsFile(CustomConf) {
  689. if err := Cfg.Append(CustomConf); err != nil {
  690. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  691. }
  692. } else {
  693. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  694. }
  695. Cfg.NameMapper = ini.AllCapsUnderscore
  696. homeDir, err := com.HomeDir()
  697. if err != nil {
  698. log.Fatal(4, "Failed to get home directory: %v", err)
  699. }
  700. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  701. LogLevel = getLogLevel("log", "LEVEL", "Info")
  702. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
  703. forcePathSeparator(LogRootPath)
  704. RedirectMacaronLog = Cfg.Section("log").Key("REDIRECT_MACARON_LOG").MustBool(false)
  705. sec := Cfg.Section("server")
  706. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  707. Protocol = HTTP
  708. if sec.Key("PROTOCOL").String() == "https" {
  709. Protocol = HTTPS
  710. CertFile = sec.Key("CERT_FILE").String()
  711. KeyFile = sec.Key("KEY_FILE").String()
  712. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  713. Protocol = FCGI
  714. } else if sec.Key("PROTOCOL").String() == "unix" {
  715. Protocol = UnixSocket
  716. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  717. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  718. if err != nil || UnixSocketPermissionParsed > 0777 {
  719. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  720. }
  721. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  722. }
  723. EnableLetsEncrypt = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
  724. LetsEncryptTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
  725. if !LetsEncryptTOS && EnableLetsEncrypt {
  726. log.Warn("Failed to enable Let's Encrypt due to Let's Encrypt TOS not being accepted")
  727. EnableLetsEncrypt = false
  728. }
  729. LetsEncryptDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
  730. LetsEncryptEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
  731. Domain = sec.Key("DOMAIN").MustString("localhost")
  732. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  733. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  734. defaultAppURL := string(Protocol) + "://" + Domain
  735. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  736. defaultAppURL += ":" + HTTPPort
  737. }
  738. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  739. AppURL = strings.TrimRight(AppURL, "/") + "/"
  740. // Check if has app suburl.
  741. url, err := url.Parse(AppURL)
  742. if err != nil {
  743. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  744. }
  745. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  746. // This value is empty if site does not have sub-url.
  747. AppSubURL = strings.TrimSuffix(url.Path, "/")
  748. AppSubURLDepth = strings.Count(AppSubURL, "/")
  749. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  750. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  751. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  752. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  753. Domain = urlHostname
  754. }
  755. var defaultLocalURL string
  756. switch Protocol {
  757. case UnixSocket:
  758. defaultLocalURL = "http://unix/"
  759. case FCGI:
  760. defaultLocalURL = AppURL
  761. default:
  762. defaultLocalURL = string(Protocol) + "://"
  763. if HTTPAddr == "0.0.0.0" {
  764. defaultLocalURL += "localhost"
  765. } else {
  766. defaultLocalURL += HTTPAddr
  767. }
  768. defaultLocalURL += ":" + HTTPPort + "/"
  769. }
  770. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  771. RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
  772. PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
  773. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  774. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  775. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
  776. AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
  777. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  778. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  779. PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
  780. if !filepath.IsAbs(PprofDataPath) {
  781. PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
  782. }
  783. switch sec.Key("LANDING_PAGE").MustString("home") {
  784. case "explore":
  785. LandingPageURL = LandingPageExplore
  786. case "organizations":
  787. LandingPageURL = LandingPageOrganizations
  788. default:
  789. LandingPageURL = LandingPageHome
  790. }
  791. if len(SSH.Domain) == 0 {
  792. SSH.Domain = Domain
  793. }
  794. SSH.RootPath = path.Join(homeDir, ".ssh")
  795. serverCiphers := sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  796. if len(serverCiphers) > 0 {
  797. SSH.ServerCiphers = serverCiphers
  798. }
  799. serverKeyExchanges := sec.Key("SSH_SERVER_KEY_EXCHANGES").Strings(",")
  800. if len(serverKeyExchanges) > 0 {
  801. SSH.ServerKeyExchanges = serverKeyExchanges
  802. }
  803. serverMACs := sec.Key("SSH_SERVER_MACS").Strings(",")
  804. if len(serverMACs) > 0 {
  805. SSH.ServerMACs = serverMACs
  806. }
  807. SSH.KeyTestPath = os.TempDir()
  808. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  809. log.Fatal(4, "Failed to map SSH settings: %v", err)
  810. }
  811. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  812. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  813. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  814. // When disable SSH, start builtin server value is ignored.
  815. if SSH.Disabled {
  816. SSH.StartBuiltinServer = false
  817. }
  818. if !SSH.Disabled && !SSH.StartBuiltinServer {
  819. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  820. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  821. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  822. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  823. }
  824. }
  825. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  826. SSH.MinimumKeySizes = map[string]int{}
  827. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  828. for _, key := range minimumKeySizes {
  829. if key.MustInt() != -1 {
  830. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  831. }
  832. }
  833. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  834. SSH.CreateAuthorizedKeysFile = sec.Key("SSH_CREATE_AUTHORIZED_KEYS_FILE").MustBool(true)
  835. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  836. sec = Cfg.Section("server")
  837. if err = sec.MapTo(&LFS); err != nil {
  838. log.Fatal(4, "Failed to map LFS settings: %v", err)
  839. }
  840. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  841. if !filepath.IsAbs(LFS.ContentPath) {
  842. LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
  843. }
  844. LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
  845. if LFS.StartServer {
  846. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  847. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  848. }
  849. LFS.JWTSecretBytes = make([]byte, 32)
  850. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  851. if err != nil || n != 32 {
  852. LFS.JWTSecretBase64, err = generate.NewJwtSecret()
  853. if err != nil {
  854. log.Fatal(4, "Error generating JWT Secret for custom config: %v", err)
  855. return
  856. }
  857. // Save secret
  858. cfg := ini.Empty()
  859. if com.IsFile(CustomConf) {
  860. // Keeps custom settings if there is already something.
  861. if err := cfg.Append(CustomConf); err != nil {
  862. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  863. }
  864. }
  865. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  866. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  867. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  868. }
  869. if err := cfg.SaveTo(CustomConf); err != nil {
  870. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  871. return
  872. }
  873. }
  874. }
  875. if err = Cfg.Section("oauth2").MapTo(&OAuth2); err != nil {
  876. log.Fatal(4, "Failed to OAuth2 settings: %v", err)
  877. return
  878. }
  879. if OAuth2.Enable {
  880. OAuth2.JWTSecretBytes = make([]byte, 32)
  881. n, err := base64.RawURLEncoding.Decode(OAuth2.JWTSecretBytes, []byte(OAuth2.JWTSecretBase64))
  882. if err != nil || n != 32 {
  883. OAuth2.JWTSecretBase64, err = generate.NewJwtSecret()
  884. if err != nil {
  885. log.Fatal(4, "error generating JWT secret: %v", err)
  886. return
  887. }
  888. cfg := ini.Empty()
  889. if com.IsFile(CustomConf) {
  890. if err := cfg.Append(CustomConf); err != nil {
  891. log.Error(4, "failed to load custom conf %s: %v", CustomConf, err)
  892. return
  893. }
  894. }
  895. cfg.Section("oauth2").Key("JWT_SECRET").SetValue(OAuth2.JWTSecretBase64)
  896. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  897. log.Fatal(4, "failed to create '%s': %v", CustomConf, err)
  898. return
  899. }
  900. if err := cfg.SaveTo(CustomConf); err != nil {
  901. log.Fatal(4, "error saving generating JWT secret to custom config: %v", err)
  902. return
  903. }
  904. }
  905. }
  906. sec = Cfg.Section("security")
  907. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  908. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  909. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  910. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  911. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  912. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  913. ReverseProxyAuthEmail = sec.Key("REVERSE_PROXY_AUTHENTICATION_EMAIL").MustString("X-WEBAUTH-EMAIL")
  914. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  915. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  916. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  917. InternalToken = loadInternalToken(sec)
  918. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  919. LogSQL = Cfg.Section("database").Key("LOG_SQL").MustBool(true)
  920. DBConnectRetries = Cfg.Section("database").Key("DB_RETRIES").MustInt(10)
  921. DBConnectBackoff = Cfg.Section("database").Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
  922. sec = Cfg.Section("attachment")
  923. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  924. if !filepath.IsAbs(AttachmentPath) {
  925. AttachmentPath = path.Join(AppWorkPath, AttachmentPath)
  926. }
  927. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  928. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  929. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  930. AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
  931. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  932. TimeFormat = map[string]string{
  933. "ANSIC": time.ANSIC,
  934. "UnixDate": time.UnixDate,
  935. "RubyDate": time.RubyDate,
  936. "RFC822": time.RFC822,
  937. "RFC822Z": time.RFC822Z,
  938. "RFC850": time.RFC850,
  939. "RFC1123": time.RFC1123,
  940. "RFC1123Z": time.RFC1123Z,
  941. "RFC3339": time.RFC3339,
  942. "RFC3339Nano": time.RFC3339Nano,
  943. "Kitchen": time.Kitchen,
  944. "Stamp": time.Stamp,
  945. "StampMilli": time.StampMilli,
  946. "StampMicro": time.StampMicro,
  947. "StampNano": time.StampNano,
  948. }[TimeFormatKey]
  949. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  950. if len(TimeFormat) == 0 {
  951. TimeFormat = TimeFormatKey
  952. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  953. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  954. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  955. }
  956. log.Trace("Custom TimeFormat: %s", TimeFormat)
  957. }
  958. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  959. // Does not check run user when the install lock is off.
  960. if InstallLock {
  961. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  962. if !match {
  963. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  964. }
  965. }
  966. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  967. // Determine and create root git repository path.
  968. sec = Cfg.Section("repository")
  969. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  970. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  971. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  972. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  973. forcePathSeparator(RepoRootPath)
  974. if !filepath.IsAbs(RepoRootPath) {
  975. RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)
  976. } else {
  977. RepoRootPath = filepath.Clean(RepoRootPath)
  978. }
  979. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  980. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  981. log.Fatal(4, "Failed to map Repository settings: %v", err)
  982. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  983. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  984. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  985. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  986. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  987. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  988. } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil {
  989. log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err)
  990. }
  991. if !filepath.IsAbs(Repository.Upload.TempPath) {
  992. Repository.Upload.TempPath = path.Join(AppWorkPath, Repository.Upload.TempPath)
  993. }
  994. sec = Cfg.Section("picture")
  995. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  996. forcePathSeparator(AvatarUploadPath)
  997. if !filepath.IsAbs(AvatarUploadPath) {
  998. AvatarUploadPath = path.Join(AppWorkPath, AvatarUploadPath)
  999. }
  1000. AvatarMaxWidth = sec.Key("AVATAR_MAX_WIDTH").MustInt(4096)
  1001. AvatarMaxHeight = sec.Key("AVATAR_MAX_HEIGHT").MustInt(3072)
  1002. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  1003. case "duoshuo":
  1004. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  1005. case "gravatar":
  1006. GravatarSource = "https://secure.gravatar.com/avatar/"
  1007. case "libravatar":
  1008. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  1009. default:
  1010. GravatarSource = source
  1011. }
  1012. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  1013. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
  1014. if OfflineMode {
  1015. DisableGravatar = true
  1016. EnableFederatedAvatar = false
  1017. }
  1018. if DisableGravatar {
  1019. EnableFederatedAvatar = false
  1020. }
  1021. if EnableFederatedAvatar || !DisableGravatar {
  1022. GravatarSourceURL, err = url.Parse(GravatarSource)
  1023. if err != nil {
  1024. log.Fatal(4, "Failed to parse Gravatar URL(%s): %v",
  1025. GravatarSource, err)
  1026. }
  1027. }
  1028. if EnableFederatedAvatar {
  1029. LibravatarService = libravatar.New()
  1030. if GravatarSourceURL.Scheme == "https" {
  1031. LibravatarService.SetUseHTTPS(true)
  1032. LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
  1033. } else {
  1034. LibravatarService.SetUseHTTPS(false)
  1035. LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
  1036. }
  1037. }
  1038. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  1039. log.Fatal(4, "Failed to map UI settings: %v", err)
  1040. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  1041. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  1042. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  1043. log.Fatal(4, "Fail to map Admin settings: %v", err)
  1044. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  1045. log.Fatal(4, "Failed to map Cron settings: %v", err)
  1046. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  1047. log.Fatal(4, "Failed to map Git settings: %v", err)
  1048. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  1049. log.Fatal(4, "Failed to map API settings: %v", err)
  1050. } else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
  1051. log.Fatal(4, "Failed to map Metrics settings: %v", err)
  1052. }
  1053. git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
  1054. sec = Cfg.Section("mirror")
  1055. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  1056. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  1057. if Mirror.MinInterval.Minutes() < 1 {
  1058. log.Warn("Mirror.MinInterval is too low")
  1059. Mirror.MinInterval = 1 * time.Minute
  1060. }
  1061. if Mirror.DefaultInterval < Mirror.MinInterval {
  1062. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  1063. Mirror.DefaultInterval = time.Hour * 8
  1064. }
  1065. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  1066. if len(Langs) == 0 {
  1067. Langs = []string{
  1068. "en-US", "zh-CN", "zh-HK", "zh-TW", "de-DE", "fr-FR", "nl-NL", "lv-LV",
  1069. "ru-RU", "uk-UA", "ja-JP", "es-ES", "pt-BR", "pl-PL", "bg-BG", "it-IT",
  1070. "fi-FI", "tr-TR", "cs-CZ", "sr-SP", "sv-SE", "ko-KR"}
  1071. }
  1072. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  1073. if len(Names) == 0 {
  1074. Names = []string{"English", "简体中文", "繁體中文(香港)", "繁體中文(台灣)", "Deutsch",
  1075. "français", "Nederlands", "latviešu", "русский", "Українська", "日本語",
  1076. "español", "português do Brasil", "polski", "български", "italiano",
  1077. "suomi", "Türkçe", "čeština", "српски", "svenska", "한국어"}
  1078. }
  1079. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  1080. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  1081. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  1082. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  1083. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  1084. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  1085. extensionReg := regexp.MustCompile(`\.\w`)
  1086. for _, sec := range Cfg.Section("markup").ChildSections() {
  1087. name := strings.TrimPrefix(sec.Name(), "markup.")
  1088. if name == "" {
  1089. log.Warn("name is empty, markup " + sec.Name() + "ignored")
  1090. continue
  1091. }
  1092. extensions := sec.Key("FILE_EXTENSIONS").Strings(",")
  1093. var exts = make([]string, 0, len(extensions))
  1094. for _, extension := range extensions {
  1095. if !extensionReg.MatchString(extension) {
  1096. log.Warn(sec.Name() + " file extension " + extension + " is invalid. Extension ignored")
  1097. } else {
  1098. exts = append(exts, extension)
  1099. }
  1100. }
  1101. if len(exts) == 0 {
  1102. log.Warn(sec.Name() + " file extension is empty, markup " + name + " ignored")
  1103. continue
  1104. }
  1105. command := sec.Key("RENDER_COMMAND").MustString("")
  1106. if command == "" {
  1107. log.Warn(" RENDER_COMMAND is empty, markup " + name + " ignored")
  1108. continue
  1109. }
  1110. ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
  1111. Enabled: sec.Key("ENABLED").MustBool(false),
  1112. MarkupName: name,
  1113. FileExtensions: exts,
  1114. Command: command,
  1115. IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
  1116. })
  1117. }
  1118. sec = Cfg.Section("U2F")
  1119. U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
  1120. U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
  1121. binVersion, err := git.BinVersion()
  1122. if err != nil {
  1123. log.Fatal(4, "Error retrieving git version: %v", err)
  1124. }
  1125. if version.Compare(binVersion, "2.9", ">=") {
  1126. // Explicitly disable credential helper, otherwise Git credentials might leak
  1127. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
  1128. }
  1129. }
  1130. func loadInternalToken(sec *ini.Section) string {
  1131. uri := sec.Key("INTERNAL_TOKEN_URI").String()
  1132. if len(uri) == 0 {
  1133. return loadOrGenerateInternalToken(sec)
  1134. }
  1135. tempURI, err := url.Parse(uri)
  1136. if err != nil {
  1137. log.Fatal(4, "Failed to parse INTERNAL_TOKEN_URI (%s): %v", uri, err)
  1138. }
  1139. switch tempURI.Scheme {
  1140. case "file":
  1141. fp, err := os.OpenFile(tempURI.RequestURI(), os.O_RDWR, 0600)
  1142. if err != nil {
  1143. log.Fatal(4, "Failed to open InternalTokenURI (%s): %v", uri, err)
  1144. }
  1145. defer fp.Close()
  1146. buf, err := ioutil.ReadAll(fp)
  1147. if err != nil {
  1148. log.Fatal(4, "Failed to read InternalTokenURI (%s): %v", uri, err)
  1149. }
  1150. // No token in the file, generate one and store it.
  1151. if len(buf) == 0 {
  1152. token, err := generate.NewInternalToken()
  1153. if err != nil {
  1154. log.Fatal(4, "Error generate internal token: %v", err)
  1155. }
  1156. if _, err := io.WriteString(fp, token); err != nil {
  1157. log.Fatal(4, "Error writing to InternalTokenURI (%s): %v", uri, err)
  1158. }
  1159. return token
  1160. }
  1161. return string(buf)
  1162. default:
  1163. log.Fatal(4, "Unsupported URI-Scheme %q (INTERNAL_TOKEN_URI = %q)", tempURI.Scheme, uri)
  1164. }
  1165. return ""
  1166. }
  1167. func loadOrGenerateInternalToken(sec *ini.Section) string {
  1168. var err error
  1169. token := sec.Key("INTERNAL_TOKEN").String()
  1170. if len(token) == 0 {
  1171. token, err = generate.NewInternalToken()
  1172. if err != nil {
  1173. log.Fatal(4, "Error generate internal token: %v", err)
  1174. }
  1175. // Save secret
  1176. cfgSave := ini.Empty()
  1177. if com.IsFile(CustomConf) {
  1178. // Keeps custom settings if there is already something.
  1179. if err := cfgSave.Append(CustomConf); err != nil {
  1180. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  1181. }
  1182. }
  1183. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(token)
  1184. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  1185. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  1186. }
  1187. if err := cfgSave.SaveTo(CustomConf); err != nil {
  1188. log.Fatal(4, "Error saving generated INTERNAL_TOKEN to custom config: %v", err)
  1189. }
  1190. }
  1191. return token
  1192. }
  1193. // NewServices initializes the services
  1194. func NewServices() {
  1195. newService()
  1196. newLogService()
  1197. NewXORMLogService(false)
  1198. newCacheService()
  1199. newSessionService()
  1200. newMailService()
  1201. newRegisterMailService()
  1202. newNotifyMailService()
  1203. newWebhookService()
  1204. newIndexerService()
  1205. }