Skip to content

Commit f89ed53

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Improve documentation for PAM and static deployment (go-gitea#21866) Add package registry cleanup rules (go-gitea#21658) Support comma-delimited string as labels in issue template (go-gitea#21831) Fix wechatwork webhook sends empty content in PR review (go-gitea#21762) Show syntax lexer name in file view/blame (go-gitea#21814) Add `context.Context` to more methods (go-gitea#21546) Timeline and color tweaks (go-gitea#21799) Fix webpack license warning (go-gitea#21815) chore: add webpack export type check (go-gitea#21857) Prevent dangling user redirects (go-gitea#21856) Fix "build from source" document to clarify the `bindata` tag is required. (go-gitea#21853) Bump loader-utils from 2.0.3 to 2.0.4 (go-gitea#21852) Do not allow Ghost access to limited visible user/org (go-gitea#21849) Fix setting HTTP headers after write (go-gitea#21833)
2 parents e7bf5f1 + 43aafc5 commit f89ed53

File tree

218 files changed

+3329
-1925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+3329
-1925
lines changed

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
727727

728728
log.Trace("Synchronizing repository releases (this may take a while)")
729729
for page := 1; ; page++ {
730-
repos, count, err := repo_model.SearchRepositoryByName(&repo_model.SearchRepoOptions{
730+
repos, count, err := repo_model.SearchRepositoryByName(ctx, &repo_model.SearchRepoOptions{
731731
ListOptions: db.ListOptions{
732732
PageSize: repo_model.RepositoryListDefaultPageSize,
733733
Page: page,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,13 @@ The following configuration set `Content-Type: application/vnd.android.package-a
289289
This includes CSS files, images, JS files and web fonts.
290290
Avatar images are dynamic resources and still served by Gitea.
291291
The option can be just a different path, as in `/static`, or another domain, as in `https://cdn.example.com`.
292-
Requests are then made as `%(ROOT_URL)s/static/css/index.css` and `https://cdn.example.com/css/index.css` respective.
292+
Requests are then made as `%(ROOT_URL)s/static/assets/css/index.css` or `https://cdn.example.com/assets/css/index.css` respectively.
293293
The static files are located in the `public/` directory of the Gitea source repository.
294+
You can proxy the STATIC_URL_PREFIX requests to Gitea server to serve the static
295+
assets, or copy the manually built Gitea assets from `$GITEA_BUILD/public` to
296+
the assets location, eg: `/var/www/assets`, make sure `$STATIC_URL_PREFIX/assets/css/index.css`
297+
points to `/var/www/assets/css/index.css`.
298+
294299
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
295300
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
296301
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.

docs/content/doc/features/authentication.en-us.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,47 @@ Uses the following fields:
166166

167167
## PAM (Pluggable Authentication Module)
168168

169-
To configure PAM, set the 'PAM Service Name' to a filename in `/etc/pam.d/`. To
170-
work with normal Linux passwords, the user running Gitea must have read access
171-
to `/etc/shadow`.
172-
173-
**Note**: PAM support is added via [build-time flags](https://docs.gitea.io/en-us/install-from-source/#build), and the official binaries provided do not have this enabled.
169+
This procedure enables PAM authentication. Users may still be added to the
170+
system manually using the user administration. PAM provides a mechanism to
171+
automatically add users to the current database by testing them against PAM
172+
authentication. To work with normal Linux passwords, the user running Gitea
173+
must also have read access to `/etc/shadow` in order to check the validity of
174+
the account when logging in using a public key.
175+
176+
**Note**: If a user has added SSH public keys into Gitea, the use of these
177+
keys _may_ bypass the login check system. Therefore, if you wish to disable a user who
178+
authenticates with PAM, you _should_ also manually disable the account in Gitea using the
179+
built-in user manager.
180+
181+
1. Configure and prepare the installation.
182+
- It is recommended that you create an administrative user.
183+
- Deselecting automatic sign-up may also be desired.
184+
1. Once the database has been initialized, log in as the newly created
185+
administrative user.
186+
1. Navigate to the user setting (icon in top-right corner), and select
187+
`Site Administration` -> `Authentication Sources`, and select
188+
`Add Authentication Source`.
189+
1. Fill out the field as follows:
190+
- `Authentication Type` : `PAM`
191+
- `Name` : Any value should be valid here, use "System Authentication" if
192+
you'd like.
193+
- `PAM Service Name` : Select the appropriate file listed under `/etc/pam.d/`
194+
that performs the authentication desired.[^1]
195+
- `PAM Email Domain` : The e-mail suffix to append to user authentication.
196+
For example, if the login system expects a user called `gituser`, and this
197+
field is set to `mail.com`, then Gitea will expect the `user email` field
198+
for an authenticated GIT instance to be `[email protected]`.[^2]
199+
200+
**Note**: PAM support is added via [build-time flags](https://docs.gitea.io/en-us/install-from-source/#build),
201+
and the official binaries provided do not have this enabled. PAM requires that
202+
the necessary libpam dynamic library be available and the necessary PAM
203+
development headers be accessible to the compiler.
204+
205+
[^1]: For example, using standard Linux log-in on Debian "Bullseye" use
206+
`common-session-noninteractive` - this value may be valid for other flavors of
207+
Debian including Ubuntu and Mint, consult your distribution's documentation.
208+
[^2]: **This is a required field for PAM**. Be aware: In the above example, the
209+
user will log into the Gitea web interface as `gituser` and not `[email protected]`
174210

175211
## SMTP (Simple Mail Transfer Protocol)
176212

docs/content/doc/installation/from-source.en-us.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ are provided to keep the build process as simple as possible.
9494

9595
Depending on requirements, the following build tags can be included.
9696

97-
- `bindata`: Build a single monolithic binary, with all assets included.
97+
- `bindata`: Build a single monolithic binary, with all assets included. Required for production build.
9898
- `sqlite sqlite_unlock_notify`: Enable support for a
9999
[SQLite3](https://sqlite.org/) database. Suggested only for tiny
100100
installations.
@@ -103,11 +103,10 @@ Depending on requirements, the following build tags can be included.
103103
available to PAM.
104104
- `gogit`: (EXPERIMENTAL) Use go-git variants of Git commands.
105105

106-
Bundling assets into the binary using the `bindata` build tag is recommended for
107-
production deployments. It is possible to serve the static assets directly via a reverse proxy,
108-
but in most cases it is not necessary, and assets should still be bundled in the binary.
109-
You may want to exclude bindata while developing/testing Gitea.
110-
To include assets, add the `bindata` tag:
106+
Bundling all assets (JS/CSS/templates, etc) into the binary. Using the `bindata` build tag is required for
107+
production deployments. You could exclude `bindata` when you are developing/testing Gitea or able to separate the assets correctly.
108+
109+
To include all assets, use the `bindata` tag:
111110

112111
```bash
113112
TAGS="bindata" make build
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
date: "2022-11-01T00:00:00+00:00"
3+
title: "Storage"
4+
slug: "packages/storage"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "storage"
11+
weight: 5
12+
identifier: "storage"
13+
---
14+
15+
# Storage
16+
17+
This document describes the storage of the package registry and how it can be managed.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Deduplication
24+
25+
The package registry has a build-in deduplication of uploaded blobs.
26+
If two identical files are uploaded only one blob is saved on the filesystem.
27+
This ensures no space is wasted for duplicated files.
28+
29+
If two packages are uploaded with identical files, both packages will display the same size but on the filesystem they require only half of the size.
30+
Whenever a package gets deleted only the references to the underlaying blobs are removed.
31+
The blobs get not removed at this moment, so they still require space on the filesystem.
32+
When a new package gets uploaded the existing blobs may get referenced again.
33+
34+
These unreferenced blobs get deleted by a [clean up job]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#cron---cleanup-expired-packages-croncleanup_packages" >}}).
35+
The config setting `OLDER_THAN` configures how long unreferenced blobs are kept before they get deleted.
36+
37+
## Cleanup Rules
38+
39+
Package registries can become large over time without cleanup.
40+
It's recommended to delete unnecessary packages and set up cleanup rules to automatically manage the package registry usage.
41+
Every package owner (user or organization) manages the cleanup rules which are applied to their packages.
42+
43+
|Setting|Description|
44+
|-|-|
45+
|Enabled|Turn the cleanup rule on or off.|
46+
|Type|Every rule manages a specific package type.|
47+
|Apply pattern to full package name|If enabled, the patterns below are applied to the full package name (`package/version`). Otherwise only the version (`version`) is used.|
48+
|Keep the most recent|How many versions to *always* keep for each package.|
49+
|Keep versions matching|The regex pattern that determines which versions to keep. An empty pattern keeps no version while `.+` keeps all versions. The container registry will always keep the `latest` version even if not configured.|
50+
|Remove versions older than|Remove only versions older than the selected days.|
51+
|Remove versions matching|The regex pattern that determines which versions to remove. An empty pattern or `.+` leads to the removal of every package if no other setting tells otherwise.|
52+
53+
Every cleanup rule can show a preview of the affected packages.
54+
This can be used to check if the cleanup rules is proper configured.
55+
56+
### Regex examples
57+
58+
Regex patterns are automatically surrounded with `\A` and `\z` anchors.
59+
Do not include any `\A`, `\z`, `^` or `$` token in the regex patterns as they are not necessary.
60+
The patterns are case-insensitive which matches the behaviour of the package registry in Gitea.
61+
62+
|Pattern|Description|
63+
|-|-|
64+
|`.*`|Match every possible version.|
65+
|`v.+`|Match versions that start with `v`.|
66+
|`release`|Match only the version `release`.|
67+
|`release.*`|Match versions that are either named or start with `release`.|
68+
|`.+-temp-.+`|Match versions that contain `-temp-`.|
69+
|`v.+\|release`|Match versions that either start with `v` or are named `release`.|
70+
|`package/v.+\|other/release`|Match versions of the package `package` that start with `v` or the version `release` of the package `other`. This needs the setting *Apply pattern to full package name* enabled.|
71+
72+
### How the cleanup rules work
73+
74+
The cleanup rules are part of the [clean up job]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#cron---cleanup-expired-packages-croncleanup_packages" >}}) and run periodicly.
75+
76+
The cleanup rule:
77+
78+
1. Collects all packages of the package type for the owners registry.
79+
1. For every package it collects all versions.
80+
1. Excludes from the list the # versions based on the *Keep the most recent* value.
81+
1. Excludes from the list any versions matching the *Keep versions matching* value.
82+
1. Excludes from the list the versions more recent than the *Remove versions older than* value.
83+
1. Excludes from the list any versions not matching the *Remove versions matching* value.
84+
1. Deletes the remaining versions.

models/activities/action.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ func DeleteOldActions(olderThan time.Duration) (err error) {
461461
return err
462462
}
463463

464-
func notifyWatchers(ctx context.Context, actions ...*Action) error {
464+
// NotifyWatchers creates batch of actions for every watcher.
465+
func NotifyWatchers(ctx context.Context, actions ...*Action) error {
465466
var watchers []*repo_model.Watch
466467
var repo *repo_model.Repository
467468
var err error
@@ -565,11 +566,6 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
565566
return nil
566567
}
567568

568-
// NotifyWatchers creates batch of actions for every watcher.
569-
func NotifyWatchers(actions ...*Action) error {
570-
return notifyWatchers(db.DefaultContext, actions...)
571-
}
572-
573569
// NotifyWatchersActions creates batch of actions for every watcher.
574570
func NotifyWatchersActions(acts []*Action) error {
575571
ctx, committer, err := db.TxContext(db.DefaultContext)
@@ -578,7 +574,7 @@ func NotifyWatchersActions(acts []*Action) error {
578574
}
579575
defer committer.Close()
580576
for _, act := range acts {
581-
if err := notifyWatchers(ctx, act); err != nil {
577+
if err := NotifyWatchers(ctx, act); err != nil {
582578
return err
583579
}
584580
}
@@ -603,17 +599,17 @@ func DeleteIssueActions(ctx context.Context, repoID, issueID int64) error {
603599
}
604600

605601
// CountActionCreatedUnixString count actions where created_unix is an empty string
606-
func CountActionCreatedUnixString() (int64, error) {
602+
func CountActionCreatedUnixString(ctx context.Context) (int64, error) {
607603
if setting.Database.UseSQLite3 {
608-
return db.GetEngine(db.DefaultContext).Where(`created_unix = ""`).Count(new(Action))
604+
return db.GetEngine(ctx).Where(`created_unix = ""`).Count(new(Action))
609605
}
610606
return 0, nil
611607
}
612608

613609
// FixActionCreatedUnixString set created_unix to zero if it is an empty string
614-
func FixActionCreatedUnixString() (int64, error) {
610+
func FixActionCreatedUnixString(ctx context.Context) (int64, error) {
615611
if setting.Database.UseSQLite3 {
616-
res, err := db.GetEngine(db.DefaultContext).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ""`)
612+
res, err := db.GetEngine(ctx).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ""`)
617613
if err != nil {
618614
return 0, err
619615
}

models/activities/action_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func TestNotifyWatchers(t *testing.T) {
188188
RepoID: 1,
189189
OpType: activities_model.ActionStarRepo,
190190
}
191-
assert.NoError(t, activities_model.NotifyWatchers(action))
191+
assert.NoError(t, activities_model.NotifyWatchers(db.DefaultContext, action))
192192

193193
// One watchers are inactive, thus action is only created for user 8, 1, 4, 11
194194
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
@@ -256,17 +256,17 @@ func TestConsistencyUpdateAction(t *testing.T) {
256256
//
257257
// Get rid of incorrectly set created_unix
258258
//
259-
count, err := activities_model.CountActionCreatedUnixString()
259+
count, err := activities_model.CountActionCreatedUnixString(db.DefaultContext)
260260
assert.NoError(t, err)
261261
assert.EqualValues(t, 1, count)
262-
count, err = activities_model.FixActionCreatedUnixString()
262+
count, err = activities_model.FixActionCreatedUnixString(db.DefaultContext)
263263
assert.NoError(t, err)
264264
assert.EqualValues(t, 1, count)
265265

266-
count, err = activities_model.CountActionCreatedUnixString()
266+
count, err = activities_model.CountActionCreatedUnixString(db.DefaultContext)
267267
assert.NoError(t, err)
268268
assert.EqualValues(t, 0, count)
269-
count, err = activities_model.FixActionCreatedUnixString()
269+
count, err = activities_model.FixActionCreatedUnixString(db.DefaultContext)
270270
assert.NoError(t, err)
271271
assert.EqualValues(t, 0, count)
272272

0 commit comments

Comments
 (0)