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