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