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

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