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