aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
Commit message (Collapse)AuthorAgeFilesLines
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-292-4/+4
| | | | | | | | | | Resolve all cases for `unused parameter` and `unnecessary type arguments` Related: #30729 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Improve oauth2 client "preferred username field" logic and the error ↵wxiaoguang2024-04-251-9/+5
| | | | | | | | | | | | | handling (#30622) Follow #30454 And fix #24957 When using "preferred_username", if no such field, `extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an error. All other USERNAME options do not return such error. And fine tune some logic and error messages, make code more stable and more friendly to end users.
* Initial support for colorblindness-friendly themes (#30625)wxiaoguang2024-04-244-6/+5
| | | | | | | Initial support for #25680 This PR only adds some simple styles from GitHub, it is big enough and it focuses on adding the necessary framework-level supports. More styles could be fine-tuned later.
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-2/+1
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Allow `preferred_username` as username source for OIDC (#30454)SimonErm2024-04-161-1/+3
| | | | | | This PR adds the preferred_username claim as a possible username source for the oauth2_client. Closes #21518
* Fix oauth2 builtin application logic (#30304)wxiaoguang2024-04-082-0/+22
| | | | | | Fix #29074 (allow to disable all builtin apps) and don't make the doctor command remove the builtin apps. By the way, rename refobject and joincond to camel case.
* Refactor startup deprecation messages (#30305)wxiaoguang2024-04-078-15/+17
| | | | | | | It doesn't change logic, it only does: 1. Rename the variable and function names 2. Use more consistent format when mentioning config section&key 3. Improve some messages
* Add `[other].SHOW_FOOTER_POWERED_BY` setting to hide `Powered by` (#30253)Yakov2024-04-031-0/+2
| | | | | | | | This allows you to hide the "Powered by" text in footer via `SHOW_FOOTER_POWERED_BY` flag in configuration. --------- Co-authored-by: silverwind <me@silverwind.io>
* Refactor "dump" sub-command (#30240)wxiaoguang2024-04-031-0/+9
| | | | | | | | | | Major changes: * Move some functions like "addReader" / "isSubDir" / "addRecursiveExclude" to a separate package, and add tests * Clarify the filename&dump type logic and add tests * Clarify the logger behavior and remove FIXME comments Co-authored-by: Giteabot <teabot@gitea.io>
* Do not allow different storage configurations to point to the same directory ↵wxiaoguang2024-03-317-15/+13
| | | | | (#30169) Replace #29171
* Add setting to disable user features when user login type is not plain (#29615)Jack Hay2024-03-291-4/+8
| | | | | | | | | ## Changes - Adds setting `EXTERNAL_USER_DISABLE_FEATURES` to disable any supported user features when login type is not plain - In general, this is necessary for SSO implementations to avoid inconsistencies between the external account management and the linked account - Adds helper functions to encourage correct use
* Remember login for a month by default (#30150)delvh2024-03-281-1/+1
| | | | | | | | | | | | | | | Previously, the default was a week. As most instances don't set the setting, this leads to a bad user experience by default. ## :warning: Breaking If your instance requires a high level of security, you may want to set `[security].LOGIN_REMEMBER_DAYS` so that logins are not valid as long. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env (#29788)Jason Song2024-03-141-0/+3
| | | | | | | | | | | | It is convenient to skip by setting environment, since it's OK to use root user in job containers. It's not a bug, but I want to backport it to v1.21 since it doesn't break anything. --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Update allowed attachment types (#29688)silverwind2024-03-091-2/+2
| | | | | Update to match GitHub's latest. Co-authored-by: Giteabot <teabot@gitea.io>
* Allow options to disable user ssh keys configuration from the interface on ↵Lunny Xiao2024-03-041-0/+1
| | | | | | | | | | | app.ini (#29447) Follow #29275 Extract from #20549 Fix #24716 --------- Co-authored-by: delvh <dev.lh@web.de>
* Fix incorrect cookie path for AppSubURL (#29534)wxiaoguang2024-03-031-2/+5
| | | Regression of #24107
* Allow options to disable user gpg keys configuration from the interface on ↵Lunny Xiao2024-03-021-1/+2
| | | | | | | | app.ini (#29486) Follow #29447 Fix #29454 Extract from #20549
* Customizable "Open with" applications for repository clone (#29320)wxiaoguang2024-02-242-14/+70
| | | | | | | | Users could customize the "clone" menu with their own application URLs on the admin panel. Replace #22378 Close #21121 Close #22149
* Allow options to disable user deletion from the interface on app.ini (#29275)Lunny Xiao2024-02-231-1/+9
| | | | | | | | | | | | | Extract from #20549 This PR added a new option on app.ini `[admin]USER_DISABLED_FEATURES` to allow the site administrator to disable users visiting deletion user interface or allow. This options are also potentially allowed to define more features in future PRs. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add slow SQL query warning (#27545)Earl Warren2024-02-231-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Databases are one of the most important parts of Forgejo, every interaction uses the database in one way or another. Therefore, it is important to maintain the database and recognize when the server is not doing well with the database. There already is the option to log *every* SQL query along with its execution time, but monitoring becomes impractical for larger instances and takes up unnecessary storage in the logs. - Add a QoL enhancement that allows instance administrators to specify a threshold value beyond which query execution time is logged as a warning in the xorm logger. The default value is a conservative five seconds to avoid this becoming a source of spam in the logs. - The use case for this patch is that with an instance the size of Codeberg, monitoring SQL logs is not very fruitful and most of them are uninteresting. Recently, in the context of persistent deadlock issues (https://codeberg.org/forgejo/forgejo/issues/220), I have noticed that certain queries hold locks on tables like comment and issue for several seconds. This patch helps to identify which queries these are and when they happen. - Added unit test. (cherry picked from commit 9cf501f1af4cd870221cef6af489618785b71186) --------- Co-authored-by: Gusted <postmaster@gusted.xyz> Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
* Use general token signing secret (#29205)wxiaoguang2024-02-183-18/+73
| | | Use a clearly defined "signing secret" for token signing.
* Refactor JWT secret generating & decoding code (#29172)wxiaoguang2024-02-162-9/+4
| | | | | | | | Old code is not consistent for generating & decoding the JWT secrets. Now, the callers only need to use 2 consistent functions: NewJwtSecretWithBase64 and DecodeJwtSecretBase64 And remove a non-common function Base64FixedDecode from util.go
* Disallow duplicate storage paths (#26484)Lunny Xiao2024-02-097-20/+42
| | | | Replace #26380
* Remove unnecessary parameter (#29092)Lunny Xiao2024-02-082-9/+3
| | | | The parameter extraConfigs has never been used anywhere. This PR just removed it. It can be taken back once it's needed.
* Fix inconsistent naming of OAuth 2.0 `ENABLE` setting (#28951)wackbyte2024-01-281-6/+13
| | | | | | | | | | | | Renames it to `ENABLED` to be consistent with other settings and deprecates it. I believe this change is necessary because other setting groups such as `attachment`, `cors`, `mailer`, etc. have an `ENABLED` setting, but `oauth2` is the only one with an `ENABLE` setting, which could cause confusion for users. This is no longer a breaking change because `ENABLE` has been set as deprecated and as an alias to `ENABLED`.
* Fix incorrect PostgreSQL connection string for Unix sockets (#28865)sdvcrx2024-01-202-2/+10
| | | Fix #28864
* Retarget depending pulls when the parent branch is deleted (#28686)Viktor Kuzmin2024-01-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes you need to work on a feature which depends on another (unmerged) feature. In this case, you may create a PR based on that feature instead of the main branch. Currently, such PRs will be closed without the possibility to reopen in case the parent feature is merged and its branch is deleted. Automatic target branch change make life a lot easier in such cases. Github and Bitbucket behave in such way. Example: $PR_1$: main <- feature1 $PR_2$: feature1 <- feature2 Currently, merging $PR_1$ and deleting its branch leads to $PR_2$ being closed without the possibility to reopen. This is both annoying and loses the review history when you open a new PR. With this change, $PR_2$ will change its target branch to main ($PR_2$: main <- feature2) after $PR_1$ has been merged and its branch has been deleted. This behavior is enabled by default but can be disabled. For security reasons, this target branch change will not be executed when merging PRs targeting another repo. Fixes #27062 Fixes #18408 --------- Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: delvh <dev.lh@web.de>
* Warn that `DISABLE_QUERY_AUTH_TOKEN` is false only if it's explicitly ↵Yarden Shoham2024-01-141-1/+4
| | | | | | | | | | defined (#28783) So we don't warn on default behavior - Fixes https://github.com/go-gitea/gitea/issues/28758 - Follows https://github.com/go-gitea/gitea/pull/28390 Signed-off-by: Yarden Shoham <git@yardenshoham.com>
* Recommend/convert to use case-sensitive collation for MySQL/MSSQL (#28662)wxiaoguang2024-01-101-3/+4
| | | | | | | | | | | | | | | | | | Mainly for MySQL/MSSQL. It is important for Gitea to use case-sensitive database charset collation. If the database is using a case-insensitive collation, Gitea will show startup error/warning messages, and show the errors/warnings on the admin panel's Self-Check page. Make `gitea doctor convert` work for MySQL to convert the collations of database & tables & columns. * Fix #28131 ## :warning: BREAKING :warning: It is not quite breaking, but it's highly recommended to convert the database&table&column to a consistent and case-sensitive collation.
* Fix panic when parsing empty pgsql host (#28708)wxiaoguang2024-01-062-1/+5
| | | | Regression of #27723 Fix #28705
* Normalize oauth email username (#28561)Kyle D2024-01-031-1/+1
|
* Add global setting how timestamps should be rendered (#28657)Yarden Shoham2024-01-021-40/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Resolves https://github.com/go-gitea/gitea/issues/22493 - Related to https://github.com/go-gitea/gitea/issues/4520 Some admins prefer all timestamps to display the full date instead of relative time. They can do that now by setting ```ini [ui] PREFERRED_TIMESTAMP_TENSE = absolute ``` This setting is set to `mixed` by default, allowing dates to render as "5 hours ago". Here are some screenshots of the UI with this setting set to `absolute`: ![image](https://github.com/go-gitea/gitea/assets/20454870/f496457f-6afa-44be-a1e7-249ee5fe0706) ![image](https://github.com/go-gitea/gitea/assets/20454870/c03b14f5-063d-4e13-9780-76ab002d76a9) ![image](https://github.com/go-gitea/gitea/assets/20454870/f4b34e28-1546-4374-9199-c43348844edd) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: delvh <dev.lh@web.de>
* Avoid cycle-redirecting user/login page (#28636)wxiaoguang2023-12-301-2/+1
| | | | Fix #28231, and remove some unused code. The `db.HasEngine` doesn't seem useful because the db engine is always initialized before web route.
* Refactor CORS handler (#28587)wxiaoguang2023-12-251-3/+1
| | | | | | | | | | | The CORS code has been unmaintained for long time, and the behavior is not correct. This PR tries to improve it. The key point is written as comment in code. And add more tests. Fix #28515 Fix #27642 Fix #17098
* Make offline mode as default to no connect external avatar service by ↵Lunny Xiao2023-12-211-1/+1
| | | | | | | default (#28548) To keep user's privacy, make offline mode as true by default. Users can still change it from installation ui and app.ini
* Always enable caches (#28527)Lunny Xiao2023-12-191-23/+0
| | | | | | | | | Nowadays, cache will be used on almost everywhere of Gitea and it cannot be disabled, otherwise some features will become unaviable. Then I think we can just remove the option for cache enable. That means cache cannot be disabled. But of course, we can still use cache configuration to set how should Gitea use the cache.
* Add option to disable ambiguous unicode characters detection (#28454)wxiaoguang2023-12-171-0/+5
| | | | | | | | * Close #24483 * Close #28123 * Close #23682 * Close #23149 (maybe more)
* Deprecate query string auth tokens (#28390)Jack Hay2023-12-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Changes - Add deprecation warning to `Token` and `AccessToken` authentication methods in swagger. - Add deprecation warning header to API response. Example: ``` HTTP/1.1 200 OK ... Warning: token and access_token API authentication is deprecated ... ``` - Add setting `DISABLE_QUERY_AUTH_TOKEN` to reject query string auth tokens entirely. Default is `false` ## Next steps - `DISABLE_QUERY_AUTH_TOKEN` should be true in a subsequent release and the methods should be removed in swagger - `DISABLE_QUERY_AUTH_TOKEN` should be removed and the implementation of the auth methods in question should be removed ## Open questions - Should there be further changes to the swagger documentation? Deprecation is not yet supported for security definitions (coming in [OpenAPI Spec version 3.2.0](https://github.com/OAI/OpenAPI-Specification/issues/2506)) - Should the API router logger sanitize urls that use `token` or `access_token`? (This is obviously an insufficient solution on its own) --------- Co-authored-by: delvh <dev.lh@web.de>
* Use `filepath` instead of `path` to create SQLite3 database file (#28374)wxiaoguang2023-12-061-2/+1
|
* Fix incorrect default value of `[attachment].MAX_SIZE` (#28373)capvor2023-12-061-1/+1
|
* add skip ci functionality (#28075)Denys Konovalov2023-11-181-2/+4
| | | | | | | | | | | | Adds the possibility to skip workflow execution if the commit message contains a string like [skip ci] or similar. The default strings are the same as on GitHub, users can also set custom ones in app.ini Reference: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs Close #28020
* Change default size of attachments and repo files (#28100)Nanguan Lin2023-11-172-2/+2
| | | | https://github.com/go-gitea/gitea/pull/27946 forgets to change them in code. Sorry about that.
* Fix incorrect pgsql conn builder behavior (#28085)wxiaoguang2023-11-172-9/+11
| | | Fix #28083 and fix the tests
* Allow to set explore page default sort (#27951)65432023-11-091-0/+1
| | | | | | | as title --- *Sponsored by Kithara Software GmbH*
* refactor postgres connection string building (#27723)Moritz Poldrack2023-11-012-29/+44
| | | | | | | | This patchset changes the connection string builder to use net.URL and the host/port parser to use the stdlib function for splitting host from port. It also adds a footnote about a potentially required portnumber for postgres UNIX sockets. Fixes: #24552
* Support storage base path as prefix (#27827)Lunny Xiao2023-11-012-3/+67
| | | | | | This PR adds a prefix path for all minio storage and override base path will override the path. The previous behavior is undefined officially, so it will be marked as breaking.
* Enhanced auth token / remember me (#27606)KN4CK3R2023-10-141-2/+0
| | | | | | | | | | | | | | | | | Closes #27455 > The mechanism responsible for long-term authentication (the 'remember me' cookie) uses a weak construction technique. It will hash the user's hashed password and the rands value; it will then call the secure cookie code, which will encrypt the user's name with the computed hash. If one were able to dump the database, they could extract those two values to rebuild that cookie and impersonate a user. That vulnerability exists from the date the dump was obtained until a user changed their password. > > To fix this security issue, the cookie could be created and verified using a different technique such as the one explained at https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence#secure-remember-me-cookies. The PR removes the now obsolete setting `COOKIE_USERNAME`.
* Increase queue length (#27555)Jason Song2023-10-101-1/+1
|
* Fix `environment-to-ini` inherited key bug (#27543)wxiaoguang2023-10-102-1/+28
| | | | | | | Fix #27541 The INI package has a quirk: by default, the keys are inherited. When maintaining the keys, the newly added sub key should not be affected by the parent key.
* Pre-register OAuth application for tea (#27509)M Hickford2023-10-081-1/+1
| | | | | | It remains to implement OAuth login in tea https://gitea.com/gitea/tea/issues/598 Fixes #27510