Commit Graph
100 Commits
Author SHA1 Message Date
99f54b2056 Add Bash and Zsh completion scripts (#22646)
This PR adds contrib scripts for bash and zsh completion.

Simply call:

```bash
source contrib/autocompletion/bash_autocomplete
```

or for Zsh:

```bash
source contrib/autocompletion/zsh_autocomplete
```

Signed-off-by: Andrew Thornton <[email protected]>

---------

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: a1012112796 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2023-02-21 12:32:24 -05:00
81543c48ca Provide the ability to set password hash algorithm parameters (#22942)
This PR refactors and improves the password hashing code within gitea
and makes it possible for server administrators to set the password
hashing parameters

In addition it takes the opportunity to adjust the settings for `pbkdf2`
in order to make the hashing a little stronger.

The majority of this work was inspired by PR #14751 and I would like to
thank @boppy for their work on this.

Thanks to @gusted for the suggestion to adjust the `pbkdf2` hashing
parameters.

Close #14751

---------

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: delvh <[email protected]>
Co-authored-by: John Olheiser <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2023-02-19 15:35:20 +08:00
zeripath 8cb1630444 Add command to bulk set must-change-password (#22823)
As part of administration sometimes it is appropriate to forcibly tell
users to update their passwords.

This PR creates a new command `gitea admin user must-change-password`
which will set the `MustChangePassword` flag on the provided users.

Signed-off-by: Andrew Thornton <[email protected]>
2023-02-14 16:12:19 -06:00
zeripath 7de99992bd Add cron method to gc LFS MetaObjects (#22385)
This PR adds a task to the cron service to allow garbage collection of
LFS meta objects. As repositories may have a large number of
LFSMetaObjects, an updated column is added to this table and it is used
to perform a generational GC to attempt to reduce the amount of work.
(There may need to be a bit more work here but this is probably enough
for the moment.)

Fix #7045

Signed-off-by: Andrew Thornton <[email protected]>
2023-01-16 13:50:53 -06:00
57e05c2a2c Add setting to disable the git apply step in test patch (#22130)
For a long time Gitea has tested PR patches using a git apply --check
method, and in fact prior to the introduction of a read-tree assisted
three-way merge in #18004, this was the only way of checking patches.

Since #18004, the git apply --check method has been a fallback method,
only used when the read-tree three-way merge method has detected a
conflict. The read-tree assisted three-way merge method is much faster
and less resource intensive method of detecting conflicts. #18004 kept
the git apply method around because it was thought possible that this
fallback might be able to rectify conflicts that the read-tree three-way
merge detected. I am not certain if this could ever be the case.

Given the uncertainty here and the now relative stability of the
read-tree method - this PR makes using this fallback optional and
disables it by default. The hope is that users will not notice any
significant difference in conflict detection and we will be able to
remove the git apply fallback in future, and/or improve the read-tree
three-way merge method to catch any conflicts that git apply method
might have been able to fix.

An additional benefit is that patch checking should be significantly
less resource intensive and much quicker.

(See
https://github.com/go-gitea/gitea/issues/22083\#issuecomment-1347961737)

Ref #22083

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: KN4CK3R <[email protected]>
2022-12-19 19:37:15 +08:00
zeripath 855b1923f0 Correct the fallbacks for mailer configuration (#21945)
Unfortunately the fallback configuration code for [mailer] that were
added in #18982 are incorrect. When you read a value from an ini section
that key is added. This leads to a failure of the fallback mechanism.
Further there is also a spelling mistake in the startTLS configuration.

This PR restructures the mailer code to first map the deprecated
settings on to the new ones - and then use ini.MapTo to map those on to
the struct with additional validation as necessary.

Ref #21744

Signed-off-by: Andrew Thornton <[email protected]>
2022-11-27 10:08:40 +00:00
zeripath 32d58714e1 Attempt clarify AppWorkPath etc. (#21656)
Attempt clarify the AppWorkPath in the documentation by using different
notation and adding a section to the start of the cheat sheet.

Fix #21523

Signed-off-by: Andrew Thornton <[email protected]>

Signed-off-by: Andrew Thornton <[email protected]>
2022-11-09 20:22:31 -05:00
d6246c6bfa Add KaTeX rendering to Markdown. (#20571)
This PR adds mathematical rendering with KaTeX.

The first step is to add a Goldmark extension that detects the latex
(and tex) mathematics delimiters.

The second step to make this extension only run if math support is
enabled.

The second step is to then add KaTeX CSS and JS to the head which will
load after the dom is rendered.

Fix #3445

Signed-off-by: Andrew Thornton <[email protected]>

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: silverwind <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2022-09-14 00:33:37 +08:00
zeripath 6ab61d3b0d Support Proxy protocol (#12527)
This PR adds functionality to allow Gitea to sit behind an
HAProxy and HAProxy protocolled connections directly.

Fix #7508

Signed-off-by: Andrew Thornton <[email protected]>
2022-08-21 19:20:43 +01:00
zeripath f31e3e0321 Allow RSA 2047 bit keys (#20272)
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix #20249

Signed-off-by: Andrew Thornton <[email protected]>
2022-07-06 16:49:27 -04:00
zeripath cf18c2ff8a Add Goroutine stack inspector to admin/monitor (#19207)
Continues on from #19202.

Following the addition of pprof labels we can now more easily understand the relationship between a goroutine and the requests that spawn them. 

This PR takes advantage of the labels and adds a few others, then provides a mechanism for the monitoring page to query the pprof goroutine profile.

The binary profile that results from this profile is immediately piped in to the google library for parsing this and then stack traces are formed for the goroutines.

If the goroutine is within a context or has been created from a goroutine within a process context it will acquire the process description labels for that process. 

The goroutines are mapped with there associate pids and any that do not have an associated pid are placed in a group at the bottom as unbound.

In this way we should be able to more easily examine goroutines that have been stuck.

A manager command `gitea manager processes` is also provided that can export the processes (with or without stacktraces) to the command line.

Signed-off-by: Andrew Thornton <[email protected]>
2022-03-31 19:01:43 +02:00
8826852966 Provide configuration to allow camo-media proxying (#12802)
* Provide configuration to allow camo-media proxying

Fix #916

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
2022-03-29 10:27:37 +02:00
zeripathandNorwin 0ec8bb3183 Make cron task no notice on success (#19221)
Change all cron tasks to make them no notice on success default. Instead if a user
wants notices on success they need to add NOTICE_ON_SUCCESS=true instead.

 ## ⚠️ BREAKING ⚠️

This changes the cron config so that notices on success are no longer set by default
and breaks NO_SUCCESS_NOTICE settings. Instead users who want notices on success
must set NOTICE_ON_SUCCESS=true instead.

Signed-off-by: Andrew Thornton <[email protected]>

* Update custom/conf/app.example.ini

Co-authored-by: Norwin <[email protected]>

Co-authored-by: Norwin <[email protected]>
2022-03-26 21:13:04 +00:00
zeripath 2778b8643a Add warning to set SENDMAIL_ARGS to -- (#19102)
Even with #17688 email addresses that contain an initial `-` may still be present in the db and it may in future still be possible to imagine a situation whereby initial `-` are repermitted.

This PR simply updates the documentation to warn users to set their SENDMAIL_ARGS with a terminal `--` to prevent this possibility email addresses being interpreted as options.

Signed-off-by: Andrew Thornton <[email protected]>
2022-03-18 15:19:02 +01:00
zeripath 7a2561c107 Update the webauthn_credential_id_sequence in Postgres (#19048)
* Update the webauthn_credential_id_sequence in Postgres

There is (yet) another problem with v210 in that Postgres will silently allow preset
ID insertions ... but it will not update the sequence value.

This PR simply adds a little step to the end of the v210 migration to update the
sequence number.

Users who have already migrated who find that they cannot insert new
webauthn_credentials into the DB can either run:

```bash
gitea doctor recreate-table webauthn_credential
```

or

```bash
./gitea doctor --run=check-db-consistency --fix
```

which will fix the bad sequence.

Fix #19012

Signed-off-by: Andrew Thornton <[email protected]>
2022-03-10 23:04:55 +01:00
zeripathandGusted f5a7d87492 Attempt to improve docs (yet again) (#18687)
* Attempt to improve docs (yet again)

Attempt to make the passthrough docs clearer.
Add some more faq entries

Signed-off-by: Andrew Thornton <[email protected]>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Gusted <[email protected]>

* Update docs/content/doc/installation/with-docker.en-us.md

* Update docs/content/doc/installation/with-docker.en-us.md

Co-authored-by: Gusted <[email protected]>
2022-02-10 19:20:06 +00:00
de2778998d Make docker gitea/gitea:v1.16-dev etc refer to the latest build on that branch (#18551)
* Make docker gitea/gitea:v1.16-dev etc refer to the latest build on that branch

One of the problems with our current docker tagging is that although we
have strict version tags, latest and dev we do not have a way for docker
users to track the current release branch. This PR simply suggests that
we use the 1.x-dev tag for these and we build and push these. This will
give users who want or need unreleased bug fixes the option of tracking
the pre-release version instead of simply jumping to dev.

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: KN4CK3R <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2022-02-03 09:47:27 +01:00
zeripath f718e91627 Update the SSH passthrough documentation (#18366) 2022-01-23 12:25:25 -05:00
zeripath 299bf615e6 Add option to convert CRLF to LF line endings for sendmail (#18075)
It appears that several versions of sendmail require that the mail is sent to them with
LF line endings instead of CRLF endings - which of course they will then convert back
to CRLF line endings to comply with the SMTP standard.

This PR adds another setting SENDMAIL_CONVERT_CRLF which will pass the message writer
through a filter. This will filter out and convert CRLFs to LFs before writing them
out to sendmail.

Fix #18024

Signed-off-by: Andrew Thornton <[email protected]>
2022-01-06 01:43:45 +01:00
4fb6d37ae7 Add Option to synchronize Admin & Restricted states from OIDC/OAuth2 along with Setting Scopes (#16766)
* Add setting to OAuth handlers to override local 2FA settings

This PR adds a setting to OAuth and OpenID login sources to allow the source to
override local 2FA requirements.

Fix #13939

Signed-off-by: Andrew Thornton <[email protected]>

* Fix regression from #16544

Signed-off-by: Andrew Thornton <[email protected]>

* Add scopes settings

Signed-off-by: Andrew Thornton <[email protected]>

* fix trace logging in auth_openid

Signed-off-by: Andrew Thornton <[email protected]>

* add required claim options

Signed-off-by: Andrew Thornton <[email protected]>

* Move UpdateExternalUser to externalaccount

Signed-off-by: Andrew Thornton <[email protected]>

* Allow OAuth2/OIDC to set Admin/Restricted status

Signed-off-by: Andrew Thornton <[email protected]>

* Allow use of the same group claim name for the prohibit login value

Signed-off-by: Andrew Thornton <[email protected]>

* fixup! Move UpdateExternalUser to externalaccount

* as per wxiaoguang

Signed-off-by: Andrew Thornton <[email protected]>

* add label back in

Signed-off-by: Andrew Thornton <[email protected]>

* adjust localisation

Signed-off-by: Andrew Thornton <[email protected]>

* placate lint

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2021-12-14 16:37:11 +08:00
zeripath 08feba0720 Make Co-committed-by and co-authored-by trailers optional (#17848)
This PR adds another option to app.ini make co-committed-by and co-authored-by trailers
optional on a per server basis.

Fix #17194

Signed-off-by: Andrew Thornton <[email protected]>
2021-11-29 07:09:55 +00:00
zeripath 6a2696030c Handle relative unix socket paths (#17836)
Make relative unix sockets absolute by making them absolute against the AppWorkPath

Fix #17833

## ⚠️ BREAKING ⚠️ 

Prior to this PR relative unix sockets would have been asserted to be relative to the current working directory that gitea, gitea serv, hook and manager etc were running in. Hooks and Serv would have failed to work properly under this situation so we expect that although this is a technically breaking change the previous situation was already broken.

Signed-off-by: Andrew Thornton <[email protected]>
2021-11-27 20:22:03 +00:00
zeripath f5883df304 Add PULL_LIMIT and PUSH_LIMIT to cron.update_mirror task (#17568) 2021-11-22 22:09:35 -05:00
zeripath cca5e51546 Make SSL cipher suite configurable (#17440) 2021-11-20 01:12:43 -05:00
zeripath ab73053c10 Add settings to allow different SMTP envelope from address (#17479)
* Add settings to allow different SMTP envelope from address

Sometimes it may be advisable to hide or alias the from address on an SMTP mail
envelope. This PR adds two new options to the mailer to allow setting of an overriding
from address.

Fix #17477

Signed-off-by: Andrew Thornton <[email protected]>
2021-11-19 23:35:20 +08:00
zeripath 89f73b06a8 Add .gitattribute assisted language detection to blame, diff and render (#17590)
Use check attribute code to check the assigned language of a file and send that in to
chroma as a hint for the language of the file.

Signed-off-by: Andrew Thornton <[email protected]>
2021-11-17 20:37:00 +00:00
zeripath e494f34cfa Make the Mirror Queue a queue (#17326)
Convert the old mirror syncing queue to the more modern queue format.

Fix a bug in the from the repo-archive queue PR - the assumption was made that uniqueness could be enforced with by checking equality in a map in channel unique queues - however this only works for primitive types - which was the initial intention but is an imperfect. This is fixed by marshalling the data and placing the martialled data in the unique map instead.

The documentation is also updated to add information about the deprecated configuration values.

Signed-off-by: Andrew Thornton <[email protected]>
2021-10-17 12:43:25 +01:00
zeripath f8a1ed5e1e Disable core.protectNTFS (#17300)
core.protectNTFS protects NTFS from files which may be difficult to remove or interact
with using the win32 api, however, it also appears to prevent such files from
being entered into the git indexes - fundamentally causing breakages with PRs that
affect these files. However, deliberately setting this to false may cause security
issues due to the remain sparse checkout of files in the merge pipeline.

The only sensible option therefore is to provide an optional setting which admins
could set which would forcibly switch this off if they are affected by this issue.

Fix #17092

Signed-off-by: Andrew Thornton <[email protected]>
2021-10-13 14:20:11 -04:00
zeripathandtechknowlogick 222675f479 Allow LDAP Sources to provide Avatars (#16851)
* Allow LDAP Sources to provide Avatars

Add setting to LDAP source to allow it to provide an Avatar.

Currently this is required to point to the image bytes.

Fix #4144

Signed-off-by: Andrew Thornton <[email protected]>

* Rename as Avatar Attribute (drop JPEG)

Signed-off-by: Andrew Thornton <[email protected]>

* Always synchronize avatar if there is change

Signed-off-by: Andrew Thornton <[email protected]>

* Actually get the avatar from the ldap

Signed-off-by: Andrew Thornton <[email protected]>

* clean-up

Signed-off-by: Andrew Thornton <[email protected]>

* use len()>0 rather than != ""

Signed-off-by: Andrew Thornton <[email protected]>

* slight shortcut in IsUploadAvatarChanged

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2021-09-26 22:39:36 -04:00
zeripath 76ddaf0e1c Add minimum versions of databases to the docs (#17080)
We do not currently state the minimum versions of databases we support.

This PR sets them to:
* MySQL >=5.7
* Postgres >=10
* MSSQL >=2008R2 SP3

Signed-off-by: Andrew Thornton <[email protected]>
2021-09-17 23:25:50 +01:00
zeripathandLunny Xiao deb2ef59b2 Add API Token Cache (#16547)
One of the issues holding back performance of the API is the problem of hashing.
Whilst banning BASIC authentication with passwords will help, the API Token scheme
still requires a PBKDF2 hash - which means that heavy API use (using Tokens) can
still cause enormous numbers of hash computations.

A slight solution to this whilst we consider moving to using JWT based tokens and/or
a session orientated solution is to simply cache the successful tokens. This has some
security issues but this should be balanced by the security issues of load from
hashing.

Related #14668

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2021-08-17 14:30:42 -04:00
zeripath 9ec149e494 Improve SMTP authentication and Fix user creation bugs (#16612)
* Improve SMTP authentication, Fix user creation bugs and add LDAP cert/key options

This PR has two parts:

Improvements for SMTP authentication:

* Default to use SMTPS if port is 465, and allow setting of force SMTPS.
* Always use STARTTLS if available
* Provide CRAM-MD5 mechanism
* Add options for HELO hostname disabling
* Add options for providing certificates and keys
* Handle application specific password response as a failed user login
instead of as a 500.

Close #16104

Fix creation of new users:

* A bug was introduced when allowing users to change usernames which
prevents the creation of external users.
* The LoginSource refactor also broke this page.

Close #16104

Signed-off-by: Andrew Thornton <[email protected]>
2021-08-11 21:42:58 +01:00
zeripathandJohn Olheiser 349a83fcba Allow setting X-FRAME-OPTIONS (#16643)
* Allow setting X-FRAME-OPTIONS

This PR provides a mechanism to set the X-FRAME-OPTIONS header.

Fix #7951

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: John Olheiser <[email protected]>

Co-authored-by: John Olheiser <[email protected]>
2021-08-06 16:47:10 -04:00
2e5f7ddd3a Make Mermaid.js limit configurable (#16519)
* Make Mermaid.js limit configurable

Add `MERMAID_MAX_SOURCE_CHARACTERS` to `[markup]` settings
to make the maximum size of a mermaid render configurable.

Fix #16513

Signed-off-by: Andrew Thornton <[email protected]>

* fixup! Make Mermaid.js limit configurable

* Update custom/conf/app.example.ini

Co-authored-by: silverwind <[email protected]>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: silverwind <[email protected]>

Co-authored-by: silverwind <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2021-07-24 00:21:51 -04:00
zeripath 215aa01560 Update documentation to reflect #15219 (#16442)
The move to render custom/public as within /assets in #15219 missed updating
several documentation pages.

This PR updates this documentation.

Signed-off-by: Andrew Thornton <[email protected]>
2021-07-15 20:49:12 +01:00
zeripath 78128ffba3 Add LRU mem cache implementation (#16226)
The current default memory cache implementation is unbounded in size and number of
objects cached. This is hardly ideal.

This PR proposes creating a TwoQueue LRU cache as the underlying cache for Gitea.
The cache is limited by the number of objects stored in the cache (rather than size)
for simplicity. The default number of objects is 50000 - which is perhaps too small
as most of our objects cached are going to be much less than 1kB.

It may be worth considering using a different LRU implementation that actively limits
sizes or avoids GC - however, this is just a beginning implementation.

Signed-off-by: Andrew Thornton <[email protected]>
2021-07-10 23:54:15 +02:00
zeripath c8b131f33d Update Go-Git to take advantage of LargeObjectThreshold (#16316)
Following the merging of https://github.com/go-git/go-git/pull/330 we
can now add a setting to avoid go-git reading and caching large objects.

Signed-off-by: Andrew Thornton <[email protected]>
2021-06-30 22:58:45 +02:00
zeripath e494e315dc Update fail2ban documentation (#16286)
Following the merge of #16278 we need to update the fail2ban
documentation to take account of the availability of the new
sshConnectionFailed failed authentication attempt log message.

Also add a deprecation notice regarding the previous publicKeyHandler
messages, as these may be a source of false positives.

Signed-off-by: Andrew Thornton <[email protected]>
2021-06-28 19:26:40 -04:00
zeripathandtechknowlogick 19e5983395 Add --quiet and --verbose to gitea web to control initial logging (#16260)
One of the repeatedly reported issues has been that gitea produces too much console
logging during set up even if the console logger is turned off.

Fundamentally this is due to some otherwise very helpful logging that has to occur
before logging is set up. This has come to a head with the merging of #16243 where
otherwise potentially helpful Trace logging in the git module now appears on the
console.

This PR proposes three things:

1. Change the initial default logger to Info not Trace.
2. Change the logging for the AppPath things to Info in recompense.
3. Add two new command line options to gitea web: --quiet and --verbose

`gitea web -q` or `gitea web --quiet` will only log Fatal level initially.
`gitea web -verbose` will log at Trace.

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2021-06-26 20:56:58 -04:00
zeripath 369144eef2 Update documentation for Implicit TLS (#16220)
As per RFC 8314, it is now recommended to prefer TLS over STARTTLS.

Fix #16160

Signed-off-by: Andrew Thornton <[email protected]>
2021-06-21 14:34:37 -04:00
zeripathandtechknowlogick 200b95f5be Clean-up the settings hierarchy for issue_indexer queue (#16001)
There are a couple of settings in `[indexer]` relating to the `issue_indexer` queue
which override settings in unpredictable ways. This PR adjusts this hierarchy and makes
explicit that these settings are deprecated.

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2021-06-16 18:19:20 -04:00
zeripathandtechknowlogick beeaa32d0b Make command in authorized keys a template (#16003)
Fix #15595
Replaces #15978

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2021-06-14 21:15:12 -04:00
zeripathand6543 a006c3ac3e Set self-adjusting deadline for connection writing (#16068)
* Set self-adjusting deadline for connection writing

In #16055 it appears that the simple 5s deadline doesn't work for large
file writes. Now we can't - or at least shouldn't just set no deadline
as go will happily let these connections block indefinitely. However,
what seems reasonable is to set some minimum rate we expect for writing.

This PR suggests the following algorithm:

* Every write has a minimum timeout of 5s (adjustable at compile time.)
* If there has been a previous write - then consider its previous
deadline, add half of the minimum timeout + 2s per kb about to written.
* If that new deadline is after the minimum timeout use that.

Fix #16055

* Linearly increase timeout

* Make PerWriteTimeout, PerWritePerKbTimeouts configurable

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
2021-06-11 00:25:25 +03:00
zeripathandsilverwind 1941d14392 Encrypt LDAP bind password in db with SECRET_KEY (#15547)
* Encrypt LDAP bind password in db with SECRET_KEY

The LDAP source bind password are currently stored in plaintext in the db
This PR simply encrypts them with the setting.SECRET_KEY.

Fix #15460

Signed-off-by: Andrew Thornton <[email protected]>

* remove ui warning regarding unencrypted password

Co-authored-by: silverwind <[email protected]>
2021-05-20 09:29:57 +01:00
zeripathandLunny Xiao ed5690bd53 Add information on how to rotate logging from outside container (#15852)
Fix #15842

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2021-05-14 00:36:23 -04:00
zeripathand6543 aaa356c08a Add ui.explore settings to control view of explore pages (2) (#14094)
This is an alternative PR to #13687.

Add `[ui.explore]` settings to allow restricting the
explore pages to logged in users only and to disable the users explore page.

The two proposed settings are:

- `REQUIRE_SIGNIN_VIEW`: Only allows access to the explore pages if the
user is signed in. Also restricts
  - `/api/v1/user/search`
  - `/api/v1/users/{username}`
  - `/api/v1/users/{username}/repos`
  - but does not restrict `/api/v1/users/{username}/heatmap`
- `DISABLE_USERS_PAGE`: Disables the /explore/users page

Fix #2908

Close #13687 

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: 6543 <[email protected]>
2021-03-11 13:40:54 +00:00
zeripath a7a6b053e6 Make internal SSH server host key path configurable (#14918)
* Make SSH server host key path configurable

* make it possible to have multiple keys

* Make gitea.rsa the default key

* Add some more logging

Signed-off-by: Andrew Thornton <[email protected]>
2021-03-08 03:43:59 +01:00
zeripath 22b925c8ae Add SameSite setting for cookies (#14900)
Add SameSite setting for cookies and rationalise the cookie setting code. Switches SameSite to Lax by default. 

There is a possible future extension of differentiating which cookies could be set at Strict by default but that is for a future PR.

Fix #5583

Signed-off-by: Andrew Thornton <[email protected]>
2021-03-07 08:12:43 +00:00
eb2a1ffda7 Create DB session provider(based on xorm) (#13031)
* Create Xorm session provider

This PR creates a Xorm session provider which creates
the appropriate Session table for macaron/session.

Fix #7137

Signed-off-by: Andrew Thornton <[email protected]>

* extraneous l

Signed-off-by: Andrew Thornton <[email protected]>

* fix lint

Signed-off-by: Andrew Thornton <[email protected]>

* use key instead of ID to be compatible with go-macaron/session

Signed-off-by: Andrew Thornton <[email protected]>

* And change the migration too.

Signed-off-by: Andrew Thornton <[email protected]>

* Update spacing of imports

Co-authored-by: 6543 <[email protected]>

* Update modules/session/xorm.go

Co-authored-by: techknowlogick <[email protected]>

* add xorm provider to the virtual provider

Signed-off-by: Andrew Thornton <[email protected]>

* prep for master merge

* prep for merge master

* As per @lunny

* move migration out of the way

* Move to call this db session as per @lunny

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2021-02-15 00:33:31 -05:00
zeripathandLunny Xiao d22294b979 Add information on how to build statically (#14594)
Fix #14576

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2021-02-08 10:06:21 +08:00
zeripathand6543 d5ae3682c5 Exclude the current dump file from the dump (#14606)
* Exclude the current dump file from the dump

Always prevent the current file from being added to the dump.

Fix #13618

Signed-off-by: Andrew Thornton <[email protected]>

* Add skip custom directory option

Signed-off-by: Andrew Thornton <[email protected]>

* placate lint

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
2021-02-08 09:00:12 +08:00
8371762553 Use native git variants by default with go-git variants as build tag (#13673)
* Move last commit cache back into modules/git

Signed-off-by: Andrew Thornton <[email protected]>

* Remove go-git from the interface for last commit cache

Signed-off-by: Andrew Thornton <[email protected]>

* move cacheref to last_commit_cache

Signed-off-by: Andrew Thornton <[email protected]>

* Remove go-git from routers/private/hook

Signed-off-by: Andrew Thornton <[email protected]>

* Move FindLFSFiles to pipeline

Signed-off-by: Andrew Thornton <[email protected]>

* Make no-go-git variants

Signed-off-by: Andrew Thornton <[email protected]>

* Submodule RefID

Signed-off-by: Andrew Thornton <[email protected]>

* fix issue with GetCommitsInfo

Signed-off-by: Andrew Thornton <[email protected]>

* fix GetLastCommitForPaths

Signed-off-by: Andrew Thornton <[email protected]>

* Improve efficiency

Signed-off-by: Andrew Thornton <[email protected]>

* More efficiency

Signed-off-by: Andrew Thornton <[email protected]>

* even faster

Signed-off-by: Andrew Thornton <[email protected]>

* Reduce duplication

* As per @lunny

Signed-off-by: Andrew Thornton <[email protected]>

* attempt to fix drone

Signed-off-by: Andrew Thornton <[email protected]>

* fix test-tags

Signed-off-by: Andrew Thornton <[email protected]>

* default to use no-go-git variants and add gogit build tag

Signed-off-by: Andrew Thornton <[email protected]>

* placate lint

Signed-off-by: Andrew Thornton <[email protected]>

* as per @6543

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-12-17 22:00:47 +08:00
5321b8a130 fix label of --id in admin delete user (#14005)
* fix label of --id in admin delete user

This pr fixes the label descriptor of `gitea admin delete user`
but also adds a `--username` option.

Fix #13995

Signed-off-by: Andrew Thornton <[email protected]>

* fix-spacing

Signed-off-by: Andrew Thornton <[email protected]>

* Add delete email support

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-12-17 02:57:32 -05:00
zeripath a978536553 Standardise logging of failed authentication attempts in internal SSH (#13962)
Continuing on from #13953 continue to improve and standardise
logging from internal SSH.

Also updates the fail2ban setup

Signed-off-by: Andrew Thornton <[email protected]>
2020-12-15 08:45:13 +00:00
zeripathandtechknowlogick 20fa482c1c Fix --port setting (#13288)
* Fix --port setting

Unfortunately there was an error in #13195 which set the --port
option before the settings were read. This PR fixes this by
moving applying this option to after the the settings are read

However, on looking further into this code I believe that the setPort
code was slightly odd.

Firstly, it may make sense to run the install page on a different
temporary port to the full system and this should be possible with
a --install-port option.

Secondy, if the --port option is provided we should apply it to both
otherwise there will be unusual behaviour on graceful restart

Thirdly, the documentation for --port says that the setting is
temporary - it should therefore not save its result to the configuration

(This however, does mean that authorized_keys and internal links may
not be correct. - I think we need to discuss this option further.)

Fix #13277

Signed-off-by: Andrew Thornton <[email protected]>

* Update cmd/web.go

* Apply suggestions from code review

Co-authored-by: techknowlogick <[email protected]>
2020-10-30 15:26:03 -04:00
zeripath 05c34201e2 Change default log configuration (#13088)
* Change default log configuration

This PR changes the install page and the docker default
logging configuration to match the suggested configuration
that I repeatedly end up suggesting on issues.

It further improves the logging configuration docs to
recommend specific instructions for how to configure logs
for posting to issues.

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/advanced/logging-documentation.en-us.md
2020-10-10 18:19:50 +03:00
64c5743751 Disable DSA ssh keys by default (#13056)
* Disable DSA ssh keys by default

OpenSSH has disabled DSA keys since version 7.0

As the docker runs openssh > v7.0 we should just disable
DSA keys by default.

Refers to #11417

Signed-off-by: Andrew Thornton <[email protected]>

* Just disable DSA keys by default

Signed-off-by: Andrew Thornton <[email protected]>

* Appears we need to set the minimum key sizes too

Signed-off-by: Andrew Thornton <[email protected]>

* Appears we need to set the minimum key sizes too

Signed-off-by: Andrew Thornton <[email protected]>

* Remove DSA type

* Fix Tests

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-10-09 09:52:57 +03:00
zeripath bc02119212 Copy missing things from app.example.ini to Cheat Sheet (#12988)
Signed-off-by: Andrew Thornton <[email protected]>
2020-10-01 07:57:57 +01:00
87f5db0a98 Allow common redis and leveldb connections (#12385)
* Allow common redis and leveldb connections

Prevents multiple reopening of redis and leveldb connections to the same
place by sharing connections.

Further allows for more configurable redis connection type using the
redisURI and a leveldbURI scheme.

Signed-off-by: Andrew Thornton <[email protected]>

* add unit-test

Signed-off-by: Andrew Thornton <[email protected]>

* as per @lunny

Signed-off-by: Andrew Thornton <[email protected]>

* add test

Signed-off-by: Andrew Thornton <[email protected]>

* Update modules/cache/cache_redis.go

* Update modules/queue/queue_disk.go

* Update modules/cache/cache_redis.go

* Update modules/cache/cache_redis.go

* Update modules/queue/unique_queue_disk.go

* Update modules/queue/queue_disk.go

* Update modules/queue/unique_queue_disk.go

* Update modules/session/redis.go

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-09-28 00:09:46 +03:00
1311c27f94 Add configurable Trust Models (#11712)
* Add configurable Trust Models

Gitea's default signature verification model differs from GitHub. GitHub
uses signatures to verify that the committer is who they say they are -
meaning that when GitHub makes a signed commit it must be the committer.
The GitHub model prevents re-publishing of commits after revocation of a
key and prevents re-signing of other people's commits to create a
completely trusted repository signed by one key or a set of trusted
keys.

The default behaviour of Gitea in contrast is to always display the
avatar and information related to a signature. This allows signatures to
be decoupled from the committer. That being said, allowing arbitary
users to present other peoples commits as theirs is not necessarily
desired therefore we have a trust model whereby signatures from
collaborators are marked trusted, signatures matching the commit line
are marked untrusted and signatures that match a user in the db but not
the committer line are marked unmatched.

The problem with this model is that this conflicts with Github therefore
we need to provide an option to allow users to choose the Github model
should they wish to.

Signed-off-by: Andrew Thornton <[email protected]>

* Adjust locale strings

Signed-off-by: Andrew Thornton <[email protected]>

* as per @6543

Co-authored-by: 6543 <[email protected]>

* Update models/gpg_key.go

* Add migration for repository

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2020-09-20 00:44:55 +08:00
zeripathandmrsdizzie b228dcdebf Add MySQL FAQ section (#12780)
* Add MySQL FAQ section

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/help/faq.en-us.md

* Update docs/content/doc/help/faq.en-us.md

Co-authored-by: mrsdizzie <[email protected]>

Co-authored-by: mrsdizzie <[email protected]>
2020-09-09 13:31:31 -04:00
zeripath b0ae3edc04 Add command to recreate tables (#12407)
Provides new command: `gitea doctor recreate-table` which will recreate
db tables and copy the old data in to the new table.

This function can be used to remove the old warning of struct defaults being
out of date.

Fix #8868
Fix #3265
Fix #8894

Signed-off-by: Andrew Thornton <[email protected]>
2020-09-06 22:52:01 +01:00
zeripathandNadim Kobeissi b1b8f74c1e Use argon as default password hash algorithm (#12688)
* Restrict TLS connections to 1.2 minimum

* Set Argon2 as the default KDF

* Fix user.yml

* Remove TLS minversion changes

Signed-off-by: Andrew Thornton <[email protected]>

* Add migration as per @techknowlogick

Signed-off-by: Andrew Thornton <[email protected]>

* set the password algo in the fixtures

Signed-off-by: Andrew Thornton <[email protected]>

* Remove the v148 migration - it needs recreate table to change the defaults

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Nadim Kobeissi <[email protected]>
2020-09-03 14:58:31 -04:00
zeripath c2951a64a5 fix documentation for REFRESH_TOKEN_EXPIRATION_TIME (#12642)
REFRESH_TOKEN_EXPIRATION_TIME refers to the refresh token not the access token

Fix #12641

Signed-off-by: Andrew Thornton <[email protected]>
2020-08-29 23:02:38 +03:00
zeripathandFlorian Klink f1c9434901 Make the default PID file compile-time settable (#12485)
#12391 offered to change the default PID file from /var/run/gitea.pid however in discussion it was decided that this could break users of older systems. An alternative was offered that we could make the PID file compile/link time settable.

This PR does this, and changes the name of the setting from CustomPID to simply PIDFile. It also updates the from-source docs to show how to change the compiler settings to do this.

Closes #12391

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Florian Klink <[email protected]>
2020-08-15 21:15:27 +01:00
aea3818e79 Pause, Resume, Release&Reopen, Add and Remove Logging from command line (#11777)
* Make LogDescriptions race safe

* Add manager commands for pausing, resuming, adding and removing loggers

Signed-off-by: Andrew Thornton <[email protected]>

* Placate lint

* Ensure that file logger is run!

* Add support for smtp and conn

Signed-off-by: Andrew Thornton <[email protected]>

* Add release-and-reopen

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-07-05 20:07:07 -04:00
8240f2e2f6 Move EventSource to SharedWorker (#12095)
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix #11978

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: silverwind <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-07-03 10:55:36 +01:00
zeripathandtechknowlogick 63733d795a Fix chardet test and add ordering option (#11621)
* Fix chardet test and add ordering option

Signed-off-by: Andrew Thornton <[email protected]>

* minor fixes

Signed-off-by: Andrew Thornton <[email protected]>

* remove log

Signed-off-by: Andrew Thornton <[email protected]>

* remove log2

Signed-off-by: Andrew Thornton <[email protected]>

* only iterate through top results

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

* slight restructure of for loop

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-06-02 19:20:19 -03:00
zeripathandguillep2k fb2917ef1c Add warning to mailer documentation about authentication (#11563)
* Add warning to mailer documentation about authentication

References #7966

Signed-off-by: Andrew Thornton <[email protected]>

* As per @guillep2k and @mrsdizzie

* as per @mrsdizzie

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: guillep2k <[email protected]>
2020-05-24 23:56:18 +01:00
853cb13b17 Allow different HardBreaks settings for documents and comments (#11515)
GH has different HardBreaks behaviour for markdown comments and documents.

Comments have hard breaks and documents have soft breaks - therefore Gitea's rendering will always be different from GH's if we only provide one setting.

Here we split the setting in to two - one for documents and one for comments and other things.

Signed-off-by: Andrew Thornton [email protected]

Changes to index.js as per @silverwind 
Co-authored-by: silverwind <[email protected]>

Changes to docs as per @guillep2k 
Co-authored-by: guillep2k <[email protected]>
2020-05-24 09:14:26 +01:00
zeripathandtechknowlogick bd164d386b Allow log.xxx.default to set logging settings for the default logger only (#11292)
* Allow log.xxx.default to set logging settings for the default logger only

Signed-off-by: Andrew Thornton <[email protected]>

* Update modules/setting/log.go

* as per @silverwind add some documentation

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-05-15 22:38:52 -04:00
zeripath 036d3840d0 Add EventSource support (#11235)
If the browser supports EventSource switch to use this instead of
polling notifications.

Signed-off-by: Andrew Thornton [email protected]
2020-05-07 22:49:00 +01:00
zeripath f8bb951e0d Sendmail should create a process on the gitea system and have a default timeout (#11256)
* Make sure that sendmail processes register with the process manager
* Provide a timeout for these (initially of 5 minutes)
* Add configurable value and tie in to documentation
* Tie in to the admin config page.

Signed-off-by: Andrew Thornton <[email protected]>
2020-05-03 00:04:31 +01:00
zeripathandLunny Xiao be288379cf Use keys.openpgp.org instead of pgp.mit.edu (#11249)
The SKS Keyserver network has been under attack with poisoned
certificates since at least 2019. Downloading a poisoned certificate has
the awful side-effect of completely breaking your keyring and most
software has now moved off the network and uses the keys.openpgp.org
which has a different protocol instead - in fact one whereby emails are
verified.

For more details regarding the attack see: https://gist.github.com/rjhansen/67ab921ffb4084c865b3618d6955275f

See: https://keys.openpgp.org/about and https://keys.openpgp.org/about/faq

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2020-04-30 12:08:43 +03:00
zeripathandsilverwind ac81fc79c9 Use AJAX for notifications table (#10961)
* Use AJAX for notifications table

Signed-off-by: Andrew Thornton <[email protected]>

* move to separate js

Signed-off-by: Andrew Thornton <[email protected]>

* placate golangci-lint

Signed-off-by: Andrew Thornton <[email protected]>

* Add autoupdating notification count

Signed-off-by: Andrew Thornton <[email protected]>

* Fix wipeall

Signed-off-by: Andrew Thornton <[email protected]>

* placate tests

Signed-off-by: Andrew Thornton <[email protected]>

* Try hidden

Signed-off-by: Andrew Thornton <[email protected]>

* Try hide and hidden

Signed-off-by: Andrew Thornton <[email protected]>

* More auto-update improvements

Only run checker on pages that have a count
Change starting checker to 10s with a back-off to 60s if there is no change

Signed-off-by: Andrew Thornton <[email protected]>

* string comparison!

Signed-off-by: Andrew Thornton <[email protected]>

* as per @silverwind

Signed-off-by: Andrew Thornton <[email protected]>

* add configurability as per @6543

Signed-off-by: Andrew Thornton <[email protected]>

* Add documentation as per @6543

Signed-off-by: Andrew Thornton <[email protected]>

* Use CSRF header not query

Signed-off-by: Andrew Thornton <[email protected]>

* Further JS improvements

Fix @etzelia update notification table request
Fix @silverwind comments

Co-Authored-By: silverwind <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>

* Simplify the notification count fns

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: silverwind <[email protected]>
2020-04-24 00:57:38 -03:00
zeripathandtechknowlogick c88e5dbe29 Add option to increase provided OAuth2 token maximum size (#11180)
Some OAuth2 providers return quite large structured tokens >32767 bytes.
Gitea currently has a fixed maximum of 32767 bytes for these and
unfortunately due to the convoluted nature of the dependent libraries the
error returned is rather opaque.

Here we manage the error a little better - detecting the rather opaque
github.com/gorilla/securecookie.errEncodedValueTooLong and converting
it to a more readable error.

Further we provide a configurable option to increase the maximum size of
the provided OAuth2 tokens.

Fix #9907

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-04-23 00:47:23 +02:00
zeripathandLauris BH 1449b6fa4b Add docs for gmail (#10995)
Fix #10971

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
2020-04-06 16:18:42 -04:00
zeripathandmrsdizzie 7872ea2d47 Add IIS Reverse Proxy documentation (#10881)
* Add IIS Reverse Proxy documentation

@mahdiit in #10748 described how to set up IIS as a reverse proxy. This
PR adds these to our documentation.

Close #10748

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/usage/reverse-proxies.en-us.md

Co-Authored-By: mrsdizzie <[email protected]>

Co-authored-by: mrsdizzie <[email protected]>
2020-03-30 00:11:15 +03:00
zeripathandLauris BH b6a7d9f63f Multiple LFS improvements (#10667)
* Add more logging in the LFS server

Adds more logging in the LFS server and stops sending internal server
error information to the client

* Add LFS Lock cursor implementation

* Simplify Claims in LFS and remove the float64 casts

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
2020-03-09 19:56:18 +00:00
9bd3c9a3c2 Add max-file-size to LFS (#10463)
* Add max-file-size to LFS

* Update modules/lfs/server.go

* As per @silverwind

Co-Authored-By: silverwind <[email protected]>

Co-authored-by: silverwind <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-02-28 01:46:57 -03:00
zeripath f439167293 Show Signer in commit lists and add basic trust (#10425)
* Show Signer in commit lists and add basic trust

Show the avatar of the signer in the commit list pages as we do not
enforce that the signer is an author or committer. This makes it
clearer who has signed the commit.

Also display commits signed by non-members differently from
members and in particular make it clear when a non-member signer
is different from the committer to help reduce the risk of
spoofing.

Signed-off-by: Andrew Thornton <[email protected]>

* ensure orange text and background is available

Signed-off-by: Andrew Thornton <[email protected]>

* Update gpg_key.go

* Update models/gpg_key.go

* Apply suggestions from code review

* Require team collaborators to have access to UnitTypeCode

* as per @6543

* fix position of sha as per @silverwind

* as per @guillep2k
2020-02-27 16:20:55 -03:00
zeripath 040f012239 Add Unique Queue infrastructure and move TestPullRequests to this (#9856)
* Upgrade levelqueue to version 0.2.0

This adds functionality for Unique Queues

* Add UniqueQueue interface and functions to create them

* Add UniqueQueue implementations

* Move TestPullRequests over to use UniqueQueue

* Reduce code duplication

* Add bytefifos

* Ensure invalid types are logged

* Fix close race in PersistableChannelQueue Shutdown
2020-02-02 23:19:58 +00:00
136b401252 Update documentation for the go module era (#9751)
* Update documentation for the go module era

use go env instead of $GOPATH

Update instructions to just use git clone

Slight update to readme

Signed-off-by: Andrew Thornton <[email protected]>

* fixup

* Apply suggestions from code review

Co-Authored-By: Antoine GIRARD <[email protected]>
Co-Authored-By: Bagas Sanjaya <[email protected]>

* Apply suggestions from code review

* Fix GOPATH settings

Co-authored-by: Antoine GIRARD <[email protected]>
Co-authored-by: Bagas Sanjaya <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-01-28 21:30:02 -05:00
zeripath 0827958b01 Make archive prefixing configurable with a global setting (#9943)
* Allow archive prefix setting

* Update copyright

* Update copyright
2020-01-22 23:46:46 +00:00
zeripathandLauris BH ed47bd2284 fix broken link (#9901)
Co-authored-by: Lauris BH <[email protected]>
2020-01-20 15:45:16 -05:00
zeripathandAntoine GIRARD f42be5e21b Add documentation to add Mermaid.js to Gitea (#9872)
* Add documentation to add mermaid to Gitea

* Update documentation

Co-authored-by: Antoine GIRARD <[email protected]>
2020-01-20 11:14:03 -05:00
zeripathandguillep2k 0c0302f9c1 Make CertFile and KeyFile relative to CustomPath (#9868)
* Make CertFile and KeyFile relative to CustomPath

The current code will absolute CertFile and KeyFile against the current working directory. This is quite unexpected for users. This code makes relative paths absolute against the CustomPath.

Fix #4196

* Improve error reporting when reading certificates

* Apply suggestions from code review

Co-Authored-By: guillep2k <[email protected]>

Co-authored-by: guillep2k <[email protected]>
2020-01-19 19:07:44 +00:00
zeripathandAntoine GIRARD 8911e30db0 Make hook status printing configurable with delay (#9641)
* Delay printing hook statuses until after 1 second

* Move to a 5s delay, wrapped writer structure and add config

* Update cmd/hook.go

* Apply suggestions from code review

* Update cmd/hook.go

Co-authored-by: Antoine GIRARD <[email protected]>
2020-01-12 08:46:03 +00:00
8e5eb5162f Graceful Queues: Issue Indexing and Tasks (#9363)
* Queue: Add generic graceful queues with settings

* Queue & Setting: Add worker pool implementation

* Queue: Add worker settings

* Queue: Make resizing worker pools

* Queue: Add name variable to queues

* Queue: Add monitoring

* Queue: Improve logging

* Issues: Gracefulise the issues indexer

Remove the old now unused specific queues

* Task: Move to generic queue and gracefulise

* Issues: Standardise the issues indexer queue settings

* Fix test

* Queue: Allow Redis to connect to unix

* Prevent deadlock during early shutdown of issue indexer

* Add MaxWorker settings to queues

* Merge branch 'master' into graceful-queues

* Update modules/indexer/issues/indexer.go

Co-Authored-By: guillep2k <[email protected]>

* Update modules/indexer/issues/indexer.go

Co-Authored-By: guillep2k <[email protected]>

* Update modules/queue/queue_channel.go

Co-Authored-By: guillep2k <[email protected]>

* Update modules/queue/queue_disk.go

* Update modules/queue/queue_disk_channel.go

Co-Authored-By: guillep2k <[email protected]>

* Rename queue.Description to queue.ManagedQueue as per @guillep2k

* Cancel pool workers when removed

* Remove dependency on queue from setting

* Update modules/queue/queue_redis.go

Co-Authored-By: guillep2k <[email protected]>

* As per @guillep2k add mutex locks on shutdown/terminate

* move unlocking out of setInternal

* Add warning if number of workers < 0

* Small changes as per @guillep2k

* No redis host specified not found

* Clean up documentation for queues

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

* Update modules/indexer/issues/indexer_test.go

* Ensure that persistable channel queue is added to manager

* Rename QUEUE_NAME REDIS_QUEUE_NAME

* Revert "Rename QUEUE_NAME REDIS_QUEUE_NAME"

This reverts commit 1f83b4fc9b9dabda186257b38c265fe7012f90df.

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2020-01-07 12:23:09 +01:00
zeripathandguillep2k c2e6f5d1bc Provide Default messages for merges (#9393)
Co-Authored-By: guillep2k <[email protected]>
2019-12-30 18:34:11 -05:00
zeripath c8e9ac5724 Use Req.URL.RequestURI() to cope with FCGI urls (#9473)
* Use Req.URL.RequestURI() to cope with FCGI urls

* Add debug logging statement when forbidden in internal API.
2019-12-24 00:11:12 +00:00
zeripath c98a365500 AuthorizedKeysCommand should not query db directly (#9371)
* AuthorizedKeysCommand should not query db directly

* Update routers/private/internal.go

* Fix import order
2019-12-16 20:49:07 -05:00
zeripath 78b8950fcd Sign protected branches (#8993)
* Move SignMerge to PullRequest

* Add approved signing mode

* As per @guillep2k comment
2019-12-15 11:06:31 +00:00
zeripath 71bcf9015c Default NO_REPLY_ADDRESS to DOMAIN (#9325)
* Default NO_REPLY_ADDRESS to DOMAIN

The default NO_REPLY_ADDRESS was previously noreply.example.org
This PR changes this to default to the default DOMAIN for gitea.

* Change default to noreply.%(DOMAIN)s

* Change default to "noreply" + Domain
2019-12-13 23:14:43 -05:00
zeripath deb632e6fd FCGI: Allow FCGI over unix sockets (#9298)
* FCGI: Allow FCGI over unix sockets

* fixup! FCGI: Allow FCGI over unix sockets
2019-12-10 13:23:26 +01:00
zeripath 3cf0754d99 Add Graceful shutdown for Windows and hooks for shutdown of goroutines (#8964)
* Graceful Shutdown for windows and others

Restructures modules/graceful, adding shutdown for windows, removing and
replacing the old minwinsvc code.

Creates a new waitGroup - terminate which allows for goroutines to
finish up after the shutdown of the servers.

Shutdown and terminate hooks are added for goroutines.

* Remove unused functions - these can be added in a different PR

* Add startup timeout functionality

* Document STARTUP_TIMEOUT
2019-11-21 13:32:02 -05:00
zeripathandAntoine GIRARD 78a5f7fffe Enforce Gitea environment for pushes (#8982)
* Enforce Gitea environment for pushes

* Update custom/conf/app.ini.sample

Co-Authored-By: Antoine GIRARD <[email protected]>
2019-11-14 22:39:48 +00:00
zeripath 942e517103 Add ALLOW_ONLY_EXTERNAL_REGISTRATION to config cheat sheet (#8986)
ALLOW_ONLY_EXTERNAL_REGISTRATION was missed off the cheat sheet. This PR adds it.

Fix #8180
2019-11-14 16:58:34 +00:00
zeripath 96738bbd00 Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
2019-11-13 07:01:19 +00:00
zeripathandguillep2k 47f66a3d55 Expose db.SetMaxOpenConns and allow non MySQL dbs to set conn pool params (#8528)
* Expose db.SetMaxOpenConns and allow other dbs to set their connection params
* Add note about port exhaustion

Co-Authored-By: guillep2k <[email protected]>
2019-10-21 22:20:47 +01:00