Commit graph

71 commits

Author SHA1 Message Date
harryzcy
a10b8dc28b
Add sudo token to /admin API 2022-11-02 01:07:11 -04:00
harryzcy
2451accb56
Add scope to teams APIs 2022-11-01 23:33:48 -04:00
harryzcy
8f03691e0a
Fix TestAPIGetAll 2022-11-01 04:02:31 -04:00
harryzcy
8b0bc32902
Disallow unauthenticated call to users/{user}/orgs 2022-11-01 03:46:37 -04:00
harryzcy
853eb68d23
One more fix 2022-11-01 02:04:09 -04:00
harryzcy
dc6ac14cc6
Fix some test but still have works to do 2022-11-01 01:47:34 -04:00
harryzcy
e8af871f98
Limit scope for /api/v1/orgs 2022-11-01 01:23:17 -04:00
harryzcy
6d7e7e5a64
Fix package integration tests 2022-10-31 00:40:10 -04:00
harryzcy
f76259b22d
Add package scope for package APIs 2022-10-31 00:13:49 -04:00
harryzcy
f45bfe3b4d
No token needed for some public info 2022-10-30 22:33:14 -04:00
harryzcy
0a8ab09258
Restrict repo scope to remaining repos endpoints 2022-10-30 21:54:55 -04:00
harryzcy
d6d6d97520
Apply repo scope to more APIs 2022-10-30 19:09:50 -04:00
harryzcy
11a51038ad
Include repo scope in TestMigrateGiteaForm 2022-10-30 17:43:08 -04:00
harryzcy
15ed960dc5
Fix several integration tests 2022-10-30 17:22:09 -04:00
harryzcy
62c9f70396
Limit repo scope on /api/v1/{user}/{repo}/issues 2022-10-30 16:57:11 -04:00
harryzcy
37c59c9136
There are so many fixes 2022-10-30 15:46:42 -04:00
harryzcy
0ff93b83ec
Add fixes for delete_repo scope 2022-10-30 05:17:46 -04:00
harryzcy
b4c35e82bb
Fix typos that causes errors 2022-10-30 04:51:06 -04:00
harryzcy
755faf6402
Fix more integration tests 2022-10-30 04:33:55 -04:00
harryzcy
a44f62e262
Add repo scope to TestAPIRepoTeams 2022-10-30 03:32:11 -04:00
harryzcy
0a837e7e88
Include repo scope in TestAPIReposRaw 2022-10-30 02:54:55 -04:00
harryzcy
f376275b07
Fix the token for repo hooks 2022-10-30 02:38:03 -04:00
harryzcy
965de5327d
Fix more repo scope issues 2022-10-30 02:35:54 -04:00
harryzcy
182b984785
Fix repo scope in TestGPGKeys again 2022-10-30 02:12:46 -04:00
harryzcy
0bee969682
Add repo scope in TestGPGKeys 2022-10-30 01:32:34 -04:00
harryzcy
a282f02de6
Limit token scope for some repo APIs 2022-10-30 01:14:12 -04:00
harryzcy
0583e79f37
Add gpg key scope to a user test 2022-10-29 22:29:32 -04:00
harryzcy
f839856e3c
Fix git tests 2022-10-29 21:43:37 -04:00
harryzcy
99f30f6f16
Add more repo scope to integration tests 2022-10-29 21:19:06 -04:00
harryzcy
1fe42fbe1a
Add repo scope to user/applications 2022-10-29 20:57:33 -04:00
harryzcy
800de93c47
Fix gpg key token tests 2022-10-29 20:43:49 -04:00
harryzcy
4464289e5c
Add scope to 'user' api 2022-10-29 19:00:43 -04:00
harryzcy
9f7db16b79
Add notification scope to TestEventSourceManagerRun 2022-10-29 18:08:54 -04:00
harryzcy
be5164b4f4
Restrict token scope for notifications 2022-10-29 15:14:59 -04:00
harryzcy
06e9c81b64
Support getting scoped token in integration tests 2022-10-29 03:36:19 -04:00
harryzcy
f3942ef05e
Revert api router and integration tests 2022-10-29 02:42:32 -04:00
Chongyi Zheng
fca8b7974e
Merge branch 'main' into access-token-scope 2022-10-29 01:15:21 -04:00
delvh
0ebb45cfe7
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-24 20:29:17 +01:00
KN4CK3R
7c11a73833
Fix package access for admins and inactive users (#21580)
I noticed an admin is not allowed to upload packages for other users
because `ctx.IsSigned` was not set.
I added a check for `user.IsActive` and `user.ProhibitLogin` too because
both was not checked. Tests enforce this now.

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-24 22:23:25 +03:00
Wayne Starr
49a4464160
Allow for resolution of NPM registry paths that match upstream (#21568)
This PR fixes issue #21567 allowing for package tarball URLs to match
the upstream registry (and GitLab/JFrog Artifactory URLs). It uses a
regex to parse the filename (which contains the NPM version) and does a
fuzzy search to pull it out. The regex was built/expanded from
http://json.schemastore.org/package,
https://github.com/Masterminds/semver, and
https://docs.npmjs.com/cli/v6/using-npm/semver and is testable here:
https://regex101.com/r/OydBJq/5

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-24 21:50:22 +08:00
M Hickford
191a74d622
Record OAuth client type at registration (#21316)
The OAuth spec [defines two types of
client](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1),
confidential and public. Previously Gitea assumed all clients to be
confidential.

> OAuth defines two client types, based on their ability to authenticate
securely with the authorization server (i.e., ability to
>   maintain the confidentiality of their client credentials):
>
>   confidential
> Clients capable of maintaining the confidentiality of their
credentials (e.g., client implemented on a secure server with
> restricted access to the client credentials), or capable of secure
client authentication using other means.
>
>   **public
> Clients incapable of maintaining the confidentiality of their
credentials (e.g., clients executing on the device used by the resource
owner, such as an installed native application or a web browser-based
application), and incapable of secure client authentication via any
other means.**
>
> The client type designation is based on the authorization server's
definition of secure authentication and its acceptable exposure levels
of client credentials. The authorization server SHOULD NOT make
assumptions about the client type.

 https://datatracker.ietf.org/doc/html/rfc8252#section-8.4

> Authorization servers MUST record the client type in the client
registration details in order to identify and process requests
accordingly.

Require PKCE for public clients:
https://datatracker.ietf.org/doc/html/rfc8252#section-8.1

> Authorization servers SHOULD reject authorization requests from native
apps that don't use PKCE by returning an error message

Fixes #21299

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-24 15:59:24 +08:00
wxiaoguang
dcd9fc7ee8
Refactor git command arguments and make all arguments to be safe to be used (#21535)
Follow #21464

Make all git command arguments strictly safe. Most changes are one-to-one replacing, keep all existing logic.
2022-10-23 22:44:45 +08:00
M Hickford
afebbf29a9
Require authentication for OAuth token refresh (#21421)
According to the OAuth spec
https://datatracker.ietf.org/doc/html/rfc6749#section-6 when "Refreshing
an Access Token"

> The authorization server MUST ... require client authentication for
confidential clients


Fixes #21418

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-23 13:28:46 +08:00
Vladimir Yakovlev
ffa4f4b570
Check for valid user token in integration tests (#21520)
Added checks for logged user token.

Some builds fail at unrelated tests, due to missing token.

Example:
https://drone.gitea.io/go-gitea/gitea/62011/2/14

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-20 19:20:01 +01:00
KN4CK3R
c3b2e44392
Add team member invite by email (#20307)
Allows to add (not registered) team members by email.

related #5353

Invite by mail:

![grafik](https://user-images.githubusercontent.com/1666336/178154779-adcc547f-c0b7-4a2a-a131-4e41a3d9d3ad.png)

Pending invitations:

![grafik](https://user-images.githubusercontent.com/1666336/178154882-9d739bb8-2b04-46c1-a025-c1f4be26af98.png)

Email:

![grafik](https://user-images.githubusercontent.com/1666336/178164716-f2f90893-7ba6-4a5e-a3db-42538a660258.png)

Join form:

![grafik](https://user-images.githubusercontent.com/1666336/178154840-aaab983a-d922-4414-b01a-9b1a19c5cef7.png)

Co-authored-by: Jack Hay <jjphay@gmail.com>
2022-10-19 14:40:28 +02:00
KN4CK3R
a577214760
Add some api integration tests (#18872)
depends on #18871

Added some api integration tests to help testing of #18798.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-18 00:23:27 +08:00
KN4CK3R
11d3677818
Enforce grouped NuGet search results (#21442)
Fixes #21434

Added tests to enforce this behaviour.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-17 01:18:09 +08:00
KN4CK3R
0e58201d1a
Add support for Chocolatey/NuGet v2 API (#21393)
Fixes #21294

This PR adds support for NuGet v2 API.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-13 18:19:39 +08:00
Neel
c35531dd11
Fix #21406: Hide repo information from file view/blame mode (#21420)
# Summary

The repo information such as description, stats and topics are getting
displayed in the top-bar when viewing a file. This has been fixed to
display the repo information only while navigating the repo and not
while viewing or blaming a file from the repo

## Before fix

Screenshot from the issue


![image](https://user-images.githubusercontent.com/47709856/195278543-9afbb735-7bd3-4f42-b3ba-da514c6989d2.png)

## After the fix

- **Repo homepage**

The repo description, topics and summary will be displayed


![image](https://user-images.githubusercontent.com/47709856/195443913-2ca967cd-6694-4a97-98d0-4d0750692b5d.png)

- **When opening a file**

The repo description, topic and summary has been conditionally hidden
from the view

<img width="1311" alt="image"
src="https://user-images.githubusercontent.com/47709856/195278964-9479231c-62ad-4c0e-b438-2018f22289db.png">

- **When running blame on a file**

> This was originally not part of the issue #21406. However the fix
seems relevant for the blame view as well.

<img width="1312" alt="image"
src="https://user-images.githubusercontent.com/47709856/195279619-02010775-aec3-4c8d-a184-d2d838c797e8.png">

- **From within a directory**

The repo description, topics and summary will not be displayed


![image](https://user-images.githubusercontent.com/47709856/195444080-ff5b2def-7e0f-47d7-b54a-7e9df5f9edd8.png)


Supporting integration tests have also been added.
2022-10-13 11:31:10 +03:00
Hubert Wawrzyńczyk
c41b30760b
Case-insensitive NuGet symbol file GUID (#21409)
NuGet symbol file lookup returned 404 on Visual Studio 2019 due to
case-sensitive api router. The api router should accept case-insensitive GUID.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-12 14:53:56 +08:00