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 43 kB

12 years ago
12 years ago
12 years ago
12 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
12 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
12 years ago
12 years ago
12 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
12 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 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
12 years ago
10 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
10 years ago
12 years ago
10 years ago
12 years ago
12 years ago
12 years ago
12 years ago
10 years ago
12 years ago
10 years ago
12 years ago
12 years ago
10 years ago
10 years ago
11 years ago
11 years ago
12 years ago
11 years ago
12 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
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
12 years ago
12 years ago
11 years ago
11 years ago
12 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
12 years ago
12 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
12 years ago
12 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
12 years ago
12 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
12 years ago
12 years ago
11 years ago
12 years ago
12 years ago
11 years ago
12 years ago
12 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
11 years ago
12 years ago
11 years ago
12 years ago
12 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
11 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  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. "crypto/rand"
  8. "encoding/base64"
  9. "fmt"
  10. "io"
  11. "net"
  12. "net/mail"
  13. "net/url"
  14. "os"
  15. "os/exec"
  16. "path"
  17. "path/filepath"
  18. "regexp"
  19. "runtime"
  20. "strconv"
  21. "strings"
  22. "time"
  23. "code.gitea.io/git"
  24. "code.gitea.io/gitea/modules/log"
  25. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  26. "code.gitea.io/gitea/modules/user"
  27. "github.com/Unknwon/com"
  28. "github.com/dgrijalva/jwt-go"
  29. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  30. _ "github.com/go-macaron/cache/redis"
  31. "github.com/go-macaron/session"
  32. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  33. "github.com/go-xorm/core"
  34. "gopkg.in/ini.v1"
  35. "strk.kbt.io/projects/go/libravatar"
  36. )
  37. // Scheme describes protocol types
  38. type Scheme string
  39. // enumerates all the scheme types
  40. const (
  41. HTTP Scheme = "http"
  42. HTTPS Scheme = "https"
  43. FCGI Scheme = "fcgi"
  44. UnixSocket Scheme = "unix"
  45. )
  46. // LandingPage describes the default page
  47. type LandingPage string
  48. // enumerates all the landing page types
  49. const (
  50. LandingPageHome LandingPage = "/"
  51. LandingPageExplore LandingPage = "/explore"
  52. )
  53. // settings
  54. var (
  55. // AppVer settings
  56. AppVer string
  57. AppBuiltWith string
  58. AppName string
  59. AppURL string
  60. AppSubURL string
  61. AppSubURLDepth int // Number of slashes
  62. AppPath string
  63. AppDataPath string
  64. // Server settings
  65. Protocol Scheme
  66. Domain string
  67. HTTPAddr string
  68. HTTPPort string
  69. LocalURL string
  70. OfflineMode bool
  71. DisableRouterLog bool
  72. CertFile string
  73. KeyFile string
  74. StaticRootPath string
  75. EnableGzip bool
  76. LandingPageURL LandingPage
  77. UnixSocketPermission uint32
  78. EnablePprof bool
  79. SSH = struct {
  80. Disabled bool `ini:"DISABLE_SSH"`
  81. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  82. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  83. Domain string `ini:"SSH_DOMAIN"`
  84. Port int `ini:"SSH_PORT"`
  85. ListenHost string `ini:"SSH_LISTEN_HOST"`
  86. ListenPort int `ini:"SSH_LISTEN_PORT"`
  87. RootPath string `ini:"SSH_ROOT_PATH"`
  88. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  89. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  90. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  91. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  92. MinimumKeySizeCheck bool `ini:"-"`
  93. MinimumKeySizes map[string]int `ini:"-"`
  94. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  95. }{
  96. Disabled: false,
  97. StartBuiltinServer: false,
  98. Domain: "",
  99. Port: 22,
  100. KeygenPath: "ssh-keygen",
  101. }
  102. LFS struct {
  103. StartServer bool `ini:"LFS_START_SERVER"`
  104. ContentPath string `ini:"LFS_CONTENT_PATH"`
  105. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  106. JWTSecretBytes []byte `ini:"-"`
  107. }
  108. // Security settings
  109. InstallLock bool
  110. SecretKey string
  111. LogInRememberDays int
  112. CookieUserName string
  113. CookieRememberName string
  114. ReverseProxyAuthUser string
  115. MinPasswordLength int
  116. ImportLocalPaths bool
  117. DisableGitHooks bool
  118. // Database settings
  119. UseSQLite3 bool
  120. UseMySQL bool
  121. UseMSSQL bool
  122. UsePostgreSQL bool
  123. UseTiDB bool
  124. // Indexer settings
  125. Indexer struct {
  126. IssuePath string
  127. UpdateQueueLength int
  128. }
  129. // Webhook settings
  130. Webhook = struct {
  131. QueueLength int
  132. DeliverTimeout int
  133. SkipTLSVerify bool
  134. Types []string
  135. PagingNum int
  136. }{
  137. QueueLength: 1000,
  138. DeliverTimeout: 5,
  139. SkipTLSVerify: false,
  140. PagingNum: 10,
  141. }
  142. // Repository settings
  143. Repository = struct {
  144. AnsiCharset string
  145. ForcePrivate bool
  146. MaxCreationLimit int
  147. MirrorQueueLength int
  148. PullRequestQueueLength int
  149. PreferredLicenses []string
  150. DisableHTTPGit bool
  151. UseCompatSSHURI bool
  152. // Repository editor settings
  153. Editor struct {
  154. LineWrapExtensions []string
  155. PreviewableFileModes []string
  156. } `ini:"-"`
  157. // Repository upload settings
  158. Upload struct {
  159. Enabled bool
  160. TempPath string
  161. AllowedTypes []string `delim:"|"`
  162. FileMaxSize int64
  163. MaxFiles int
  164. } `ini:"-"`
  165. // Repository local settings
  166. Local struct {
  167. LocalCopyPath string
  168. } `ini:"-"`
  169. }{
  170. AnsiCharset: "",
  171. ForcePrivate: false,
  172. MaxCreationLimit: -1,
  173. MirrorQueueLength: 1000,
  174. PullRequestQueueLength: 1000,
  175. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  176. DisableHTTPGit: false,
  177. UseCompatSSHURI: false,
  178. // Repository editor settings
  179. Editor: struct {
  180. LineWrapExtensions []string
  181. PreviewableFileModes []string
  182. }{
  183. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  184. PreviewableFileModes: []string{"markdown"},
  185. },
  186. // Repository upload settings
  187. Upload: struct {
  188. Enabled bool
  189. TempPath string
  190. AllowedTypes []string `delim:"|"`
  191. FileMaxSize int64
  192. MaxFiles int
  193. }{
  194. Enabled: true,
  195. TempPath: "data/tmp/uploads",
  196. AllowedTypes: []string{},
  197. FileMaxSize: 3,
  198. MaxFiles: 5,
  199. },
  200. // Repository local settings
  201. Local: struct {
  202. LocalCopyPath string
  203. }{
  204. LocalCopyPath: "tmp/local-repo",
  205. },
  206. }
  207. RepoRootPath string
  208. ScriptType = "bash"
  209. // UI settings
  210. UI = struct {
  211. ExplorePagingNum int
  212. IssuePagingNum int
  213. FeedMaxCommitNum int
  214. ThemeColorMetaTag string
  215. MaxDisplayFileSize int64
  216. ShowUserEmail bool
  217. Admin struct {
  218. UserPagingNum int
  219. RepoPagingNum int
  220. NoticePagingNum int
  221. OrgPagingNum int
  222. } `ini:"ui.admin"`
  223. User struct {
  224. RepoPagingNum int
  225. } `ini:"ui.user"`
  226. Meta struct {
  227. Author string
  228. Description string
  229. Keywords string
  230. } `ini:"ui.meta"`
  231. }{
  232. ExplorePagingNum: 20,
  233. IssuePagingNum: 10,
  234. FeedMaxCommitNum: 5,
  235. ThemeColorMetaTag: `#6cc644`,
  236. MaxDisplayFileSize: 8388608,
  237. Admin: struct {
  238. UserPagingNum int
  239. RepoPagingNum int
  240. NoticePagingNum int
  241. OrgPagingNum int
  242. }{
  243. UserPagingNum: 50,
  244. RepoPagingNum: 50,
  245. NoticePagingNum: 25,
  246. OrgPagingNum: 50,
  247. },
  248. User: struct {
  249. RepoPagingNum int
  250. }{
  251. RepoPagingNum: 15,
  252. },
  253. Meta: struct {
  254. Author string
  255. Description string
  256. Keywords string
  257. }{
  258. Author: "Gitea - Git with a cup of tea",
  259. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  260. Keywords: "go,git,self-hosted,gitea",
  261. },
  262. }
  263. // Markdown settings
  264. Markdown = struct {
  265. EnableHardLineBreak bool
  266. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  267. FileExtensions []string
  268. }{
  269. EnableHardLineBreak: false,
  270. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  271. }
  272. // Admin settings
  273. Admin struct {
  274. DisableRegularOrgCreation bool
  275. }
  276. // Picture settings
  277. AvatarUploadPath string
  278. GravatarSource string
  279. DisableGravatar bool
  280. EnableFederatedAvatar bool
  281. LibravatarService *libravatar.Libravatar
  282. // Log settings
  283. LogRootPath string
  284. LogModes []string
  285. LogConfigs []string
  286. // Attachment settings
  287. AttachmentPath string
  288. AttachmentAllowedTypes string
  289. AttachmentMaxSize int64
  290. AttachmentMaxFiles int
  291. AttachmentEnabled bool
  292. // Time settings
  293. TimeFormat string
  294. // Cache settings
  295. CacheAdapter string
  296. CacheInterval int
  297. CacheConn string
  298. // Session settings
  299. SessionConfig session.Options
  300. CSRFCookieName = "_csrf"
  301. // Cron tasks
  302. Cron = struct {
  303. UpdateMirror struct {
  304. Enabled bool
  305. RunAtStart bool
  306. Schedule string
  307. } `ini:"cron.update_mirrors"`
  308. RepoHealthCheck struct {
  309. Enabled bool
  310. RunAtStart bool
  311. Schedule string
  312. Timeout time.Duration
  313. Args []string `delim:" "`
  314. } `ini:"cron.repo_health_check"`
  315. CheckRepoStats struct {
  316. Enabled bool
  317. RunAtStart bool
  318. Schedule string
  319. } `ini:"cron.check_repo_stats"`
  320. ArchiveCleanup struct {
  321. Enabled bool
  322. RunAtStart bool
  323. Schedule string
  324. OlderThan time.Duration
  325. } `ini:"cron.archive_cleanup"`
  326. SyncExternalUsers struct {
  327. Enabled bool
  328. RunAtStart bool
  329. Schedule string
  330. UpdateExisting bool
  331. } `ini:"cron.sync_external_users"`
  332. }{
  333. UpdateMirror: struct {
  334. Enabled bool
  335. RunAtStart bool
  336. Schedule string
  337. }{
  338. Enabled: true,
  339. RunAtStart: false,
  340. Schedule: "@every 10m",
  341. },
  342. RepoHealthCheck: struct {
  343. Enabled bool
  344. RunAtStart bool
  345. Schedule string
  346. Timeout time.Duration
  347. Args []string `delim:" "`
  348. }{
  349. Enabled: true,
  350. RunAtStart: false,
  351. Schedule: "@every 24h",
  352. Timeout: 60 * time.Second,
  353. Args: []string{},
  354. },
  355. CheckRepoStats: struct {
  356. Enabled bool
  357. RunAtStart bool
  358. Schedule string
  359. }{
  360. Enabled: true,
  361. RunAtStart: true,
  362. Schedule: "@every 24h",
  363. },
  364. ArchiveCleanup: struct {
  365. Enabled bool
  366. RunAtStart bool
  367. Schedule string
  368. OlderThan time.Duration
  369. }{
  370. Enabled: true,
  371. RunAtStart: true,
  372. Schedule: "@every 24h",
  373. OlderThan: 24 * time.Hour,
  374. },
  375. SyncExternalUsers: struct {
  376. Enabled bool
  377. RunAtStart bool
  378. Schedule string
  379. UpdateExisting bool
  380. }{
  381. Enabled: true,
  382. RunAtStart: false,
  383. Schedule: "@every 24h",
  384. UpdateExisting: true,
  385. },
  386. }
  387. // Git settings
  388. Git = struct {
  389. Version string `ini:"-"`
  390. DisableDiffHighlight bool
  391. MaxGitDiffLines int
  392. MaxGitDiffLineCharacters int
  393. MaxGitDiffFiles int
  394. GCArgs []string `delim:" "`
  395. Timeout struct {
  396. Migrate int
  397. Mirror int
  398. Clone int
  399. Pull int
  400. GC int `ini:"GC"`
  401. } `ini:"git.timeout"`
  402. }{
  403. DisableDiffHighlight: false,
  404. MaxGitDiffLines: 1000,
  405. MaxGitDiffLineCharacters: 500,
  406. MaxGitDiffFiles: 100,
  407. GCArgs: []string{},
  408. Timeout: struct {
  409. Migrate int
  410. Mirror int
  411. Clone int
  412. Pull int
  413. GC int `ini:"GC"`
  414. }{
  415. Migrate: 600,
  416. Mirror: 300,
  417. Clone: 300,
  418. Pull: 300,
  419. GC: 60,
  420. },
  421. }
  422. // Mirror settings
  423. Mirror struct {
  424. DefaultInterval time.Duration
  425. MinInterval time.Duration
  426. }
  427. // API settings
  428. API = struct {
  429. MaxResponseItems int
  430. }{
  431. MaxResponseItems: 50,
  432. }
  433. // I18n settings
  434. Langs []string
  435. Names []string
  436. dateLangs map[string]string
  437. // Highlight settings are loaded in modules/template/highlight.go
  438. // Other settings
  439. ShowFooterBranding bool
  440. ShowFooterVersion bool
  441. ShowFooterTemplateLoadTime bool
  442. // Global setting objects
  443. Cfg *ini.File
  444. CustomPath string // Custom directory path
  445. CustomConf string
  446. CustomPID string
  447. ProdMode bool
  448. RunUser string
  449. IsWindows bool
  450. HasRobotsTxt bool
  451. InternalToken string // internal access token
  452. IterateBufferSize int
  453. )
  454. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  455. func DateLang(lang string) string {
  456. name, ok := dateLangs[lang]
  457. if ok {
  458. return name
  459. }
  460. return "en"
  461. }
  462. // execPath returns the executable path.
  463. func execPath() (string, error) {
  464. execFile := os.Args[0]
  465. if IsWindows && filepath.IsAbs(execFile) {
  466. return filepath.Clean(execFile), nil
  467. }
  468. file, err := exec.LookPath(execFile)
  469. if err != nil {
  470. return "", err
  471. }
  472. return filepath.Abs(file)
  473. }
  474. func init() {
  475. IsWindows = runtime.GOOS == "windows"
  476. log.NewLogger(0, "console", `{"level": 0}`)
  477. var err error
  478. if AppPath, err = execPath(); err != nil {
  479. log.Fatal(4, "Failed to get app path: %v", err)
  480. }
  481. // Note: we don't use path.Dir here because it does not handle case
  482. // which path starts with two "/" in Windows: "//psf/Home/..."
  483. AppPath = strings.Replace(AppPath, "\\", "/", -1)
  484. }
  485. // WorkDir returns absolute path of work directory.
  486. func WorkDir() (string, error) {
  487. wd := os.Getenv("GITEA_WORK_DIR")
  488. if len(wd) > 0 {
  489. return wd, nil
  490. }
  491. // Use GOGS_WORK_DIR if available, for backward compatibility
  492. // TODO: drop in 1.1.0 ?
  493. wd = os.Getenv("GOGS_WORK_DIR")
  494. if len(wd) > 0 {
  495. log.Warn(`Usage of GOGS_WORK_DIR is deprecated and will be *removed* in a future release,
  496. please consider changing to GITEA_WORK_DIR`)
  497. return wd, nil
  498. }
  499. i := strings.LastIndex(AppPath, "/")
  500. if i == -1 {
  501. return AppPath, nil
  502. }
  503. return AppPath[:i], nil
  504. }
  505. func forcePathSeparator(path string) {
  506. if strings.Contains(path, "\\") {
  507. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  508. }
  509. }
  510. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  511. // actual user that runs the app. The first return value is the actual user name.
  512. // This check is ignored under Windows since SSH remote login is not the main
  513. // method to login on Windows.
  514. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  515. if IsWindows {
  516. return "", true
  517. }
  518. currentUser := user.CurrentUsername()
  519. return currentUser, runUser == currentUser
  520. }
  521. func createPIDFile(pidPath string) {
  522. currentPid := os.Getpid()
  523. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  524. log.Fatal(4, "Failed to create PID folder: %v", err)
  525. }
  526. file, err := os.Create(pidPath)
  527. if err != nil {
  528. log.Fatal(4, "Failed to create PID file: %v", err)
  529. }
  530. defer file.Close()
  531. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  532. log.Fatal(4, "Failed to write PID information: %v", err)
  533. }
  534. }
  535. // NewContext initializes configuration context.
  536. // NOTE: do not print any log except error.
  537. func NewContext() {
  538. workDir, err := WorkDir()
  539. if err != nil {
  540. log.Fatal(4, "Failed to get work directory: %v", err)
  541. }
  542. Cfg = ini.Empty()
  543. CustomPath = os.Getenv("GITEA_CUSTOM")
  544. if len(CustomPath) == 0 {
  545. CustomPath = workDir + "/custom"
  546. }
  547. if len(CustomPID) > 0 {
  548. createPIDFile(CustomPID)
  549. }
  550. if len(CustomConf) == 0 {
  551. CustomConf = CustomPath + "/conf/app.ini"
  552. } else if !filepath.IsAbs(CustomConf) {
  553. CustomConf = filepath.Join(workDir, CustomConf)
  554. }
  555. if com.IsFile(CustomConf) {
  556. if err = Cfg.Append(CustomConf); err != nil {
  557. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  558. }
  559. } else {
  560. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  561. }
  562. Cfg.NameMapper = ini.AllCapsUnderscore
  563. homeDir, err := com.HomeDir()
  564. if err != nil {
  565. log.Fatal(4, "Failed to get home directory: %v", err)
  566. }
  567. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  568. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log"))
  569. forcePathSeparator(LogRootPath)
  570. sec := Cfg.Section("server")
  571. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  572. Protocol = HTTP
  573. if sec.Key("PROTOCOL").String() == "https" {
  574. Protocol = HTTPS
  575. CertFile = sec.Key("CERT_FILE").String()
  576. KeyFile = sec.Key("KEY_FILE").String()
  577. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  578. Protocol = FCGI
  579. } else if sec.Key("PROTOCOL").String() == "unix" {
  580. Protocol = UnixSocket
  581. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  582. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  583. if err != nil || UnixSocketPermissionParsed > 0777 {
  584. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  585. }
  586. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  587. }
  588. Domain = sec.Key("DOMAIN").MustString("localhost")
  589. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  590. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  591. defaultAppURL := string(Protocol) + "://" + Domain
  592. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  593. defaultAppURL += ":" + HTTPPort
  594. }
  595. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  596. AppURL = strings.TrimRight(AppURL, "/") + "/"
  597. // Check if has app suburl.
  598. url, err := url.Parse(AppURL)
  599. if err != nil {
  600. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  601. }
  602. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  603. // This value is empty if site does not have sub-url.
  604. AppSubURL = strings.TrimSuffix(url.Path, "/")
  605. AppSubURLDepth = strings.Count(AppSubURL, "/")
  606. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  607. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  608. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  609. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  610. Domain = urlHostname
  611. }
  612. var defaultLocalURL string
  613. switch Protocol {
  614. case UnixSocket:
  615. defaultLocalURL = "http://unix/"
  616. case FCGI:
  617. defaultLocalURL = AppURL
  618. default:
  619. defaultLocalURL = string(Protocol) + "://"
  620. if HTTPAddr == "0.0.0.0" {
  621. defaultLocalURL += "localhost"
  622. } else {
  623. defaultLocalURL += HTTPAddr
  624. }
  625. defaultLocalURL += ":" + HTTPPort + "/"
  626. }
  627. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  628. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  629. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  630. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
  631. AppDataPath = sec.Key("APP_DATA_PATH").MustString("data")
  632. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  633. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  634. switch sec.Key("LANDING_PAGE").MustString("home") {
  635. case "explore":
  636. LandingPageURL = LandingPageExplore
  637. default:
  638. LandingPageURL = LandingPageHome
  639. }
  640. if len(SSH.Domain) == 0 {
  641. SSH.Domain = Domain
  642. }
  643. SSH.RootPath = path.Join(homeDir, ".ssh")
  644. SSH.ServerCiphers = sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  645. SSH.KeyTestPath = os.TempDir()
  646. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  647. log.Fatal(4, "Failed to map SSH settings: %v", err)
  648. }
  649. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  650. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  651. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  652. // When disable SSH, start builtin server value is ignored.
  653. if SSH.Disabled {
  654. SSH.StartBuiltinServer = false
  655. }
  656. if !SSH.Disabled && !SSH.StartBuiltinServer {
  657. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  658. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  659. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  660. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  661. }
  662. }
  663. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  664. SSH.MinimumKeySizes = map[string]int{}
  665. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  666. for _, key := range minimumKeySizes {
  667. if key.MustInt() != -1 {
  668. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  669. }
  670. }
  671. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  672. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  673. sec = Cfg.Section("server")
  674. if err = sec.MapTo(&LFS); err != nil {
  675. log.Fatal(4, "Failed to map LFS settings: %v", err)
  676. }
  677. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  678. if !filepath.IsAbs(LFS.ContentPath) {
  679. LFS.ContentPath = filepath.Join(workDir, LFS.ContentPath)
  680. }
  681. if LFS.StartServer {
  682. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  683. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  684. }
  685. LFS.JWTSecretBytes = make([]byte, 32)
  686. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  687. if err != nil || n != 32 {
  688. //Generate new secret and save to config
  689. _, err := io.ReadFull(rand.Reader, LFS.JWTSecretBytes)
  690. if err != nil {
  691. log.Fatal(4, "Error reading random bytes: %v", err)
  692. }
  693. LFS.JWTSecretBase64 = base64.RawURLEncoding.EncodeToString(LFS.JWTSecretBytes)
  694. // Save secret
  695. cfg := ini.Empty()
  696. if com.IsFile(CustomConf) {
  697. // Keeps custom settings if there is already something.
  698. if err := cfg.Append(CustomConf); err != nil {
  699. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  700. }
  701. }
  702. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  703. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  704. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  705. }
  706. if err := cfg.SaveTo(CustomConf); err != nil {
  707. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  708. return
  709. }
  710. }
  711. //Disable LFS client hooks if installed for the current OS user
  712. //Needs at least git v2.1.2
  713. binVersion, err := git.BinVersion()
  714. if err != nil {
  715. log.Fatal(4, "Error retrieving git version: %v", err)
  716. }
  717. splitVersion := strings.SplitN(binVersion, ".", 4)
  718. majorVersion, err := strconv.ParseUint(splitVersion[0], 10, 64)
  719. if err != nil {
  720. log.Fatal(4, "Error parsing git major version: %v", err)
  721. }
  722. minorVersion, err := strconv.ParseUint(splitVersion[1], 10, 64)
  723. if err != nil {
  724. log.Fatal(4, "Error parsing git minor version: %v", err)
  725. }
  726. revisionVersion, err := strconv.ParseUint(splitVersion[2], 10, 64)
  727. if err != nil {
  728. log.Fatal(4, "Error parsing git revision version: %v", err)
  729. }
  730. if !((majorVersion > 2) || (majorVersion == 2 && minorVersion > 1) ||
  731. (majorVersion == 2 && minorVersion == 1 && revisionVersion >= 2)) {
  732. LFS.StartServer = false
  733. log.Error(4, "LFS server support needs at least Git v2.1.2")
  734. } else {
  735. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  736. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  737. }
  738. }
  739. sec = Cfg.Section("security")
  740. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  741. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  742. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  743. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  744. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  745. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  746. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  747. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  748. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  749. InternalToken = sec.Key("INTERNAL_TOKEN").String()
  750. if len(InternalToken) == 0 {
  751. secretBytes := make([]byte, 32)
  752. _, err := io.ReadFull(rand.Reader, secretBytes)
  753. if err != nil {
  754. log.Fatal(4, "Error reading random bytes: %v", err)
  755. }
  756. secretKey := base64.RawURLEncoding.EncodeToString(secretBytes)
  757. now := time.Now()
  758. InternalToken, err = jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
  759. "nbf": now.Unix(),
  760. }).SignedString([]byte(secretKey))
  761. if err != nil {
  762. log.Fatal(4, "Error generate internal token: %v", err)
  763. }
  764. // Save secret
  765. cfgSave := ini.Empty()
  766. if com.IsFile(CustomConf) {
  767. // Keeps custom settings if there is already something.
  768. if err := cfgSave.Append(CustomConf); err != nil {
  769. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  770. }
  771. }
  772. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(InternalToken)
  773. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  774. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  775. }
  776. if err := cfgSave.SaveTo(CustomConf); err != nil {
  777. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  778. }
  779. }
  780. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  781. sec = Cfg.Section("attachment")
  782. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  783. if !filepath.IsAbs(AttachmentPath) {
  784. AttachmentPath = path.Join(workDir, AttachmentPath)
  785. }
  786. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  787. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  788. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  789. AttachmentEnabled = sec.Key("ENABLE").MustBool(true)
  790. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  791. TimeFormat = map[string]string{
  792. "ANSIC": time.ANSIC,
  793. "UnixDate": time.UnixDate,
  794. "RubyDate": time.RubyDate,
  795. "RFC822": time.RFC822,
  796. "RFC822Z": time.RFC822Z,
  797. "RFC850": time.RFC850,
  798. "RFC1123": time.RFC1123,
  799. "RFC1123Z": time.RFC1123Z,
  800. "RFC3339": time.RFC3339,
  801. "RFC3339Nano": time.RFC3339Nano,
  802. "Kitchen": time.Kitchen,
  803. "Stamp": time.Stamp,
  804. "StampMilli": time.StampMilli,
  805. "StampMicro": time.StampMicro,
  806. "StampNano": time.StampNano,
  807. }[TimeFormatKey]
  808. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  809. if len(TimeFormat) == 0 {
  810. TimeFormat = TimeFormatKey
  811. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  812. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  813. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  814. }
  815. log.Trace("Custom TimeFormat: %s", TimeFormat)
  816. }
  817. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  818. // Does not check run user when the install lock is off.
  819. if InstallLock {
  820. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  821. if !match {
  822. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  823. }
  824. }
  825. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  826. // Determine and create root git repository path.
  827. sec = Cfg.Section("repository")
  828. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  829. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  830. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  831. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  832. forcePathSeparator(RepoRootPath)
  833. if !filepath.IsAbs(RepoRootPath) {
  834. RepoRootPath = path.Join(workDir, RepoRootPath)
  835. } else {
  836. RepoRootPath = path.Clean(RepoRootPath)
  837. }
  838. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  839. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  840. log.Fatal(4, "Failed to map Repository settings: %v", err)
  841. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  842. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  843. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  844. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  845. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  846. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  847. }
  848. if !filepath.IsAbs(Repository.Upload.TempPath) {
  849. Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
  850. }
  851. sec = Cfg.Section("picture")
  852. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  853. forcePathSeparator(AvatarUploadPath)
  854. if !filepath.IsAbs(AvatarUploadPath) {
  855. AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
  856. }
  857. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  858. case "duoshuo":
  859. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  860. case "gravatar":
  861. GravatarSource = "https://secure.gravatar.com/avatar/"
  862. case "libravatar":
  863. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  864. default:
  865. GravatarSource = source
  866. }
  867. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  868. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool()
  869. if OfflineMode {
  870. DisableGravatar = true
  871. EnableFederatedAvatar = false
  872. }
  873. if DisableGravatar {
  874. EnableFederatedAvatar = false
  875. }
  876. if EnableFederatedAvatar {
  877. LibravatarService = libravatar.New()
  878. parts := strings.Split(GravatarSource, "/")
  879. if len(parts) >= 3 {
  880. if parts[0] == "https:" {
  881. LibravatarService.SetUseHTTPS(true)
  882. LibravatarService.SetSecureFallbackHost(parts[2])
  883. } else {
  884. LibravatarService.SetUseHTTPS(false)
  885. LibravatarService.SetFallbackHost(parts[2])
  886. }
  887. }
  888. }
  889. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  890. log.Fatal(4, "Failed to map UI settings: %v", err)
  891. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  892. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  893. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  894. log.Fatal(4, "Fail to map Admin settings: %v", err)
  895. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  896. log.Fatal(4, "Failed to map Cron settings: %v", err)
  897. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  898. log.Fatal(4, "Failed to map Git settings: %v", err)
  899. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  900. log.Fatal(4, "Failed to map API settings: %v", err)
  901. }
  902. sec = Cfg.Section("mirror")
  903. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  904. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  905. if Mirror.MinInterval.Minutes() < 1 {
  906. log.Warn("Mirror.MinInterval is too low")
  907. Mirror.MinInterval = 1 * time.Minute
  908. }
  909. if Mirror.DefaultInterval < Mirror.MinInterval {
  910. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  911. Mirror.DefaultInterval = time.Hour * 8
  912. }
  913. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  914. if len(Langs) == 0 {
  915. Langs = defaultLangs
  916. }
  917. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  918. if len(Names) == 0 {
  919. Names = defaultLangNames
  920. }
  921. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  922. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  923. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  924. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  925. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  926. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  927. }
  928. // Service settings
  929. var Service struct {
  930. ActiveCodeLives int
  931. ResetPwdCodeLives int
  932. RegisterEmailConfirm bool
  933. DisableRegistration bool
  934. ShowRegistrationButton bool
  935. RequireSignInView bool
  936. EnableNotifyMail bool
  937. EnableReverseProxyAuth bool
  938. EnableReverseProxyAutoRegister bool
  939. EnableCaptcha bool
  940. DefaultKeepEmailPrivate bool
  941. DefaultAllowCreateOrganization bool
  942. DefaultEnableTimetracking bool
  943. DefaultAllowOnlyContributorsToTrackTime bool
  944. NoReplyAddress string
  945. // OpenID settings
  946. EnableOpenIDSignIn bool
  947. EnableOpenIDSignUp bool
  948. OpenIDWhitelist []*regexp.Regexp
  949. OpenIDBlacklist []*regexp.Regexp
  950. }
  951. func newService() {
  952. sec := Cfg.Section("service")
  953. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  954. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  955. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  956. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration)
  957. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  958. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  959. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  960. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
  961. Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
  962. Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
  963. Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
  964. Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
  965. Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
  966. sec = Cfg.Section("openid")
  967. Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(false)
  968. Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
  969. pats := sec.Key("WHITELISTED_URIS").Strings(" ")
  970. if len(pats) != 0 {
  971. Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
  972. for i, p := range pats {
  973. Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
  974. }
  975. }
  976. pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
  977. if len(pats) != 0 {
  978. Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
  979. for i, p := range pats {
  980. Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
  981. }
  982. }
  983. }
  984. var logLevels = map[string]string{
  985. "Trace": "0",
  986. "Debug": "1",
  987. "Info": "2",
  988. "Warn": "3",
  989. "Error": "4",
  990. "Critical": "5",
  991. }
  992. func newLogService() {
  993. log.Info("Gitea v%s%s", AppVer, AppBuiltWith)
  994. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  995. LogConfigs = make([]string, len(LogModes))
  996. useConsole := false
  997. for i := 0; i < len(LogModes); i++ {
  998. LogModes[i] = strings.TrimSpace(LogModes[i])
  999. if LogModes[i] == "console" {
  1000. useConsole = true
  1001. }
  1002. }
  1003. if !useConsole {
  1004. log.DelLogger("console")
  1005. }
  1006. for i, mode := range LogModes {
  1007. sec, err := Cfg.GetSection("log." + mode)
  1008. if err != nil {
  1009. sec, _ = Cfg.NewSection("log." + mode)
  1010. }
  1011. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  1012. // Log level.
  1013. levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
  1014. Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
  1015. validLevels)
  1016. level, ok := logLevels[levelName]
  1017. if !ok {
  1018. log.Fatal(4, "Unknown log level: %s", levelName)
  1019. }
  1020. // Generate log configuration.
  1021. switch mode {
  1022. case "console":
  1023. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  1024. case "file":
  1025. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gitea.log"))
  1026. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1027. panic(err.Error())
  1028. }
  1029. LogConfigs[i] = fmt.Sprintf(
  1030. `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1031. logPath,
  1032. sec.Key("LOG_ROTATE").MustBool(true),
  1033. sec.Key("MAX_LINES").MustInt(1000000),
  1034. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1035. sec.Key("DAILY_ROTATE").MustBool(true),
  1036. sec.Key("MAX_DAYS").MustInt(7))
  1037. case "conn":
  1038. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1039. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1040. sec.Key("RECONNECT").MustBool(),
  1041. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1042. sec.Key("ADDR").MustString(":7020"))
  1043. case "smtp":
  1044. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":["%s"],"subject":"%s"}`, level,
  1045. sec.Key("USER").MustString("example@example.com"),
  1046. sec.Key("PASSWD").MustString("******"),
  1047. sec.Key("HOST").MustString("127.0.0.1:25"),
  1048. strings.Replace(sec.Key("RECEIVERS").MustString("example@example.com"), ",", "\",\"", -1),
  1049. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1050. case "database":
  1051. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1052. sec.Key("DRIVER").String(),
  1053. sec.Key("CONN").String())
  1054. }
  1055. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  1056. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  1057. }
  1058. }
  1059. // NewXORMLogService initializes xorm logger service
  1060. func NewXORMLogService(disableConsole bool) {
  1061. logModes := strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  1062. var logConfigs string
  1063. for _, mode := range logModes {
  1064. mode = strings.TrimSpace(mode)
  1065. if disableConsole && mode == "console" {
  1066. continue
  1067. }
  1068. sec, err := Cfg.GetSection("log." + mode)
  1069. if err != nil {
  1070. sec, _ = Cfg.NewSection("log." + mode)
  1071. }
  1072. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  1073. // Log level.
  1074. levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
  1075. Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
  1076. validLevels)
  1077. level, ok := logLevels[levelName]
  1078. if !ok {
  1079. log.Fatal(4, "Unknown log level: %s", levelName)
  1080. }
  1081. // Generate log configuration.
  1082. switch mode {
  1083. case "console":
  1084. logConfigs = fmt.Sprintf(`{"level":%s}`, level)
  1085. case "file":
  1086. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "xorm.log"))
  1087. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1088. panic(err.Error())
  1089. }
  1090. logPath = filepath.Join(filepath.Dir(logPath), "xorm.log")
  1091. logConfigs = fmt.Sprintf(
  1092. `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1093. logPath,
  1094. sec.Key("LOG_ROTATE").MustBool(true),
  1095. sec.Key("MAX_LINES").MustInt(1000000),
  1096. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1097. sec.Key("DAILY_ROTATE").MustBool(true),
  1098. sec.Key("MAX_DAYS").MustInt(7))
  1099. case "conn":
  1100. logConfigs = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1101. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1102. sec.Key("RECONNECT").MustBool(),
  1103. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1104. sec.Key("ADDR").MustString(":7020"))
  1105. case "smtp":
  1106. logConfigs = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
  1107. sec.Key("USER").MustString("example@example.com"),
  1108. sec.Key("PASSWD").MustString("******"),
  1109. sec.Key("HOST").MustString("127.0.0.1:25"),
  1110. sec.Key("RECEIVERS").MustString("[]"),
  1111. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1112. case "database":
  1113. logConfigs = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1114. sec.Key("DRIVER").String(),
  1115. sec.Key("CONN").String())
  1116. }
  1117. log.NewXORMLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, logConfigs)
  1118. if !disableConsole {
  1119. log.Info("XORM Log Mode: %s(%s)", strings.Title(mode), levelName)
  1120. }
  1121. var lvl core.LogLevel
  1122. switch levelName {
  1123. case "Trace", "Debug":
  1124. lvl = core.LOG_DEBUG
  1125. case "Info":
  1126. lvl = core.LOG_INFO
  1127. case "Warn":
  1128. lvl = core.LOG_WARNING
  1129. case "Error", "Critical":
  1130. lvl = core.LOG_ERR
  1131. }
  1132. log.XORMLogger.SetLevel(lvl)
  1133. }
  1134. if len(logConfigs) == 0 {
  1135. log.DiscardXORMLogger()
  1136. }
  1137. }
  1138. func newCacheService() {
  1139. CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
  1140. switch CacheAdapter {
  1141. case "memory":
  1142. CacheInterval = Cfg.Section("cache").Key("INTERVAL").MustInt(60)
  1143. case "redis", "memcache":
  1144. CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
  1145. default:
  1146. log.Fatal(4, "Unknown cache adapter: %s", CacheAdapter)
  1147. }
  1148. log.Info("Cache Service Enabled")
  1149. }
  1150. func newSessionService() {
  1151. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  1152. []string{"memory", "file", "redis", "mysql"})
  1153. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
  1154. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
  1155. SessionConfig.CookiePath = AppSubURL
  1156. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
  1157. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  1158. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  1159. log.Info("Session Service Enabled")
  1160. }
  1161. // Mailer represents mail service.
  1162. type Mailer struct {
  1163. // Mailer
  1164. QueueLength int
  1165. Name string
  1166. From string
  1167. FromName string
  1168. FromEmail string
  1169. SendAsPlainText bool
  1170. // SMTP sender
  1171. Host string
  1172. User, Passwd string
  1173. DisableHelo bool
  1174. HeloHostname string
  1175. SkipVerify bool
  1176. UseCertificate bool
  1177. CertFile, KeyFile string
  1178. // Sendmail sender
  1179. UseSendmail bool
  1180. SendmailPath string
  1181. }
  1182. var (
  1183. // MailService the global mailer
  1184. MailService *Mailer
  1185. )
  1186. func newMailService() {
  1187. sec := Cfg.Section("mailer")
  1188. // Check mailer setting.
  1189. if !sec.Key("ENABLED").MustBool() {
  1190. return
  1191. }
  1192. MailService = &Mailer{
  1193. QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
  1194. Name: sec.Key("NAME").MustString(AppName),
  1195. SendAsPlainText: sec.Key("SEND_AS_PLAIN_TEXT").MustBool(false),
  1196. Host: sec.Key("HOST").String(),
  1197. User: sec.Key("USER").String(),
  1198. Passwd: sec.Key("PASSWD").String(),
  1199. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  1200. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  1201. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  1202. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  1203. CertFile: sec.Key("CERT_FILE").String(),
  1204. KeyFile: sec.Key("KEY_FILE").String(),
  1205. UseSendmail: sec.Key("USE_SENDMAIL").MustBool(),
  1206. SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"),
  1207. }
  1208. MailService.From = sec.Key("FROM").MustString(MailService.User)
  1209. if sec.HasKey("ENABLE_HTML_ALTERNATIVE") {
  1210. log.Warn("ENABLE_HTML_ALTERNATIVE is deprecated, use SEND_AS_PLAIN_TEXT")
  1211. MailService.SendAsPlainText = !sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false)
  1212. }
  1213. parsed, err := mail.ParseAddress(MailService.From)
  1214. if err != nil {
  1215. log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
  1216. }
  1217. MailService.FromName = parsed.Name
  1218. MailService.FromEmail = parsed.Address
  1219. log.Info("Mail Service Enabled")
  1220. }
  1221. func newRegisterMailService() {
  1222. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  1223. return
  1224. } else if MailService == nil {
  1225. log.Warn("Register Mail Service: Mail Service is not enabled")
  1226. return
  1227. }
  1228. Service.RegisterEmailConfirm = true
  1229. log.Info("Register Mail Service Enabled")
  1230. }
  1231. func newNotifyMailService() {
  1232. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  1233. return
  1234. } else if MailService == nil {
  1235. log.Warn("Notify Mail Service: Mail Service is not enabled")
  1236. return
  1237. }
  1238. Service.EnableNotifyMail = true
  1239. log.Info("Notify Mail Service Enabled")
  1240. }
  1241. func newWebhookService() {
  1242. sec := Cfg.Section("webhook")
  1243. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  1244. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  1245. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  1246. Webhook.Types = []string{"gitea", "gogs", "slack", "discord"}
  1247. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  1248. }
  1249. // NewServices initializes the services
  1250. func NewServices() {
  1251. newService()
  1252. newLogService()
  1253. NewXORMLogService(false)
  1254. newCacheService()
  1255. newSessionService()
  1256. newMailService()
  1257. newRegisterMailService()
  1258. newNotifyMailService()
  1259. newWebhookService()
  1260. }