Commit graph

1010 commits

Author SHA1 Message Date
Anbraten
7d7ba755cc
Fix secret priority (#2599) 2023-10-16 23:39:55 +02:00
Oskars
afef609f3c
Adjust github scopes and clarify documentation. (#2578)
Add scopes needed when creating Github application.
Removed "repo:status" scope, because it is included in already requested
"repo" scope.

Fixes: #1081
2023-10-14 13:26:25 +02:00
qwerty287
0e5defa807
Refactor/simplify pubsub (#2554) 2023-10-13 07:34:33 +02:00
renovate[bot]
b1cedecc42
fix(deps): update module github.com/google/go-github/v55 to v56 (#2573) 2023-10-12 15:28:00 +02:00
Anbraten
62d6a6bc34
Move skip-ci back in front of config fetching (#2555) 2023-10-09 18:15:53 +02:00
qwerty287
53b79eabcd
Add test for handling pipeline error (#2547)
Credits: @langecode

Taken from #2504
2023-10-08 14:58:13 +02:00
Michalis Zampetakis
259ff78a62
Fix PR event trigger and list for bitbucket repos (#2539)
Co-authored-by: Anbraten <anton@ju60.de>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-10-08 14:18:49 +02:00
qwerty287
22dfd2ef62
Refactor pipeline parsing and forge refreshing (#2527)
- refactor pipeline parsing
- do not parse the pipeline multiple times to perform filter checks, do
this once and perform checks on the result directly
    - code deduplication
- refactor forge token refreshing
    - move refreshing to a helper func to reduce code

---------

Co-authored-by: Anbraten <anton@ju60.de>
2023-10-08 14:05:06 +02:00
qwerty287
6699577aba
Fix ccmenu endpoint (#2543) 2023-10-07 18:59:59 +02:00
qwerty287
3bd53b379e
Fix gitlab hooks and simplify config extension (#2537)
- closes #2534 
- remove `IsConfigured` func from config extension.
  If `server.Config.Services.ConfigService != nil` it is always configured
2023-10-07 16:41:25 +02:00
renovate[bot]
14fb564629
fix(deps): update golang deps non-major (#2533) 2023-10-06 17:33:06 +02:00
Martin W. Kirst
570141eae7
Use correct mime type when no content is sent (#2515)
closes #2514 

The fix is simple, just providing a file name, so
`http.ServeContent(...)` can set the correct mimeype in case the content
is zero bytes.

The test was just extended.

PS: I would appreciate a `hacktoberfest-accepted` label ;)

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-10-03 12:28:20 +02:00
renovate[bot]
64951d6a9e
fix(deps): update golang deps non-major (#2500) 2023-09-30 09:23:11 +02:00
Michalis Zampetakis
57b7b1788d
Fix bitbucket branches pagination. (#2509) 2023-09-29 18:01:29 +02:00
qwerty287
ecdc729cdc
Some cleanups about host config (#2490) 2023-09-23 07:54:23 +02:00
Tom Kneiphof
baaf8b97e1
Fix usage of WOODPECKER_ROOT_PATH (#2485)
I had experienced some issues running Woodpecker behind a reverse-proxy,
resulting from not defining the `WOODPECKER_ROOT_PATH` environment
variable in #2477.

As suggested by @qwerty287, specifying `WOODPECKER_ROOT_PATH=/foo`
*mostly* solved the issue of running the woodpecker server at an url
like `https://example.org/foo`.
However, the webhook urls and badge urls were generated excluding the
configured `WOODPECKER_ROOT_PATH`.

This PR (mostly) fixes issues related to non-empty
`WOODPECKER_ROOT_PATH`.

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-09-22 16:43:31 +02:00
qwerty287
29e93bdf8b
Never log tokens (#2466) 2023-09-16 10:53:37 +02:00
renovate[bot]
3d19d863d1
fix(deps): update module github.com/tevino/abool to v2 (#2460) 2023-09-14 07:34:36 +02:00
renovate[bot]
3eced32b81
fix(deps): update module github.com/google/go-github/v39 to v55 (#2456) 2023-09-13 14:49:39 +02:00
renovate[bot]
97a7438ab1
fix(deps): update module github.com/golang-jwt/jwt/v4 to v5 (#2449)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/golang-jwt/jwt/v4](https://togithub.com/golang-jwt/jwt) |
require | major | `v4.5.0` -> `v5.0.0` |

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the
Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>golang-jwt/jwt (github.com/golang-jwt/jwt/v4)</summary>

### [`v5.0.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.0.0)

[Compare
Source](https://togithub.com/golang-jwt/jwt/compare/v4.5.0...v5.0.0)

### 🚀 New Major Version `v5` 🚀

It's finally here, the release you have been waiting for! We don't take
breaking changes lightly, but the changes outlined below were necessary
to address some of the challenges of the previous API. A big thanks for
[@&#8203;mfridman](https://togithub.com/mfridman) for all the reviews,
all contributors for their commits and of course
[@&#8203;dgrijalva](https://togithub.com/dgrijalva) for the original
code. I hope we kept some of the spirit of your original `v4` branch
alive in the approach we have taken here.
\~[@&#8203;oxisto](https://togithub.com/oxisto), on behalf of
[@&#8203;golang-jwt/maintainers](https://togithub.com/golang-jwt/maintainers)

Version `v5` contains a major rework of core functionalities in the
`jwt-go` library. This includes support for several validation options
as well as a re-design of the `Claims` interface. Lastly, we reworked
how errors work under the hood, which should provide a better overall
developer experience.

Starting from
[v5.0.0](https://togithub.com/golang-jwt/jwt/releases/tag/v5.0.0), the
import path will be:

    "github.com/golang-jwt/jwt/v5"

For most users, changing the import path *should* suffice. However,
since we intentionally changed and cleaned some of the public API,
existing programs might need to be updated. The following sections
describe significant changes and corresponding updates for existing
programs.

#### Parsing and Validation Options

Under the hood, a new `validator` struct takes care of validating the
claims. A long awaited feature has been the option to fine-tune the
validation of tokens. This is now possible with several `ParserOption`
functions that can be appended to most `Parse` functions, such as
`ParseWithClaims`. The most important options and changes are:

- Added `WithLeeway` to support specifying the leeway that is allowed
when validating time-based claims, such as `exp` or `nbf`.
- Changed default behavior to not check the `iat` claim. Usage of this
claim is OPTIONAL according to the JWT RFC. The claim itself is also
purely informational according to the RFC, so a strict validation
failure is not recommended. If you want to check for sensible values in
these claims, please use the `WithIssuedAt` parser option.
- Added `WithAudience`, `WithSubject` and `WithIssuer` to support
checking for expected `aud`, `sub` and `iss`.
- Added `WithStrictDecoding` and `WithPaddingAllowed` options to allow
previously global settings to enable base64 strict encoding and the
parsing of base64 strings with padding. The latter is strictly speaking
against the standard, but unfortunately some of the major identity
providers issue some of these incorrect tokens. Both options are
disabled by default.

#### Changes to the `Claims` interface

##### Complete Restructuring

Previously, the claims interface was satisfied with an implementation of
a `Valid() error` function. This had several issues:

- The different claim types (struct claims, map claims, etc.) then
contained similar (but not 100 % identical) code of how this validation
was done. This lead to a lot of (almost) duplicate code and was hard to
maintain
- It was not really semantically close to what a "claim" (or a set of
claims) really is; which is a list of defined key/value pairs with a
certain semantic meaning.

Since all the validation functionality is now extracted into the
validator, all `VerifyXXX` and `Valid` functions have been removed from
the `Claims` interface. Instead, the interface now represents a list of
getters to retrieve values with a specific meaning. This allows us to
completely decouple the validation logic with the underlying storage
representation of the claim, which could be a struct, a map or even
something stored in a database.

```go
type Claims interface {
	GetExpirationTime() (*NumericDate, error)
	GetIssuedAt() (*NumericDate, error)
	GetNotBefore() (*NumericDate, error)
	GetIssuer() (string, error)
	GetSubject() (string, error)
	GetAudience() (ClaimStrings, error)
}
```

##### Supported Claim Types and Removal of `StandardClaims`

The two standard claim types supported by this library, `MapClaims` and
`RegisteredClaims` both implement the necessary functions of this
interface. The old `StandardClaims` struct, which has already been
deprecated in `v4` is now removed.

Users using custom claims, in most cases, will not experience any
changes in the behavior as long as they embedded `RegisteredClaims`. If
they created a new claim type from scratch, they now need to implemented
the proper getter functions.

##### Migrating Application Specific Logic of the old `Valid`

Previously, users could override the `Valid` method in a custom claim,
for example to extend the validation with application-specific claims.
However, this was always very dangerous, since once could easily disable
the standard validation and signature checking.

In order to avoid that, while still supporting the use-case, a new
`ClaimsValidator` interface has been introduced. This interface consists
of the `Validate() error` function. If the validator sees, that a
`Claims` struct implements this interface, the errors returned to the
`Validate` function will be *appended* to the regular standard
validation. It is not possible to disable the standard validation
anymore (even only by accident).

Usage examples can be found in [example_test.go](./example_test.go), to
build claims structs like the following.

```go
// MyCustomClaims includes all registered claims, plus Foo.
type MyCustomClaims struct {
	Foo string `json:"foo"`
	jwt.RegisteredClaims
}

// Validate can be used to execute additional application-specific claims
// validation.
func (m MyCustomClaims) Validate() error {
	if m.Foo != "bar" {
		return errors.New("must be foobar")
	}

	return nil
}
```

#### Changes to the `Token` and `Parser` struct

The previously global functions `DecodeSegment` and `EncodeSegment` were
moved to the `Parser` and `Token` struct respectively. This will allow
us in the future to configure the behavior of these two based on options
supplied on the parser or the token (creation). This also removes two
previously global variables and moves them to parser options
`WithStrictDecoding` and `WithPaddingAllowed`.

In order to do that, we had to adjust the way signing methods work.
Previously they were given a base64 encoded signature in `Verify` and
were expected to return a base64 encoded version of the signature in
`Sign`, both as a `string`. However, this made it necessary to have
`DecodeSegment` and `EncodeSegment` global and was a less than perfect
design because we were repeating encoding/decoding steps for all signing
methods. Now, `Sign` and `Verify` operate on a decoded signature as a
`[]byte`, which feels more natural for a cryptographic operation anyway.
Lastly, `Parse` and `SignedString` take care of the final
encoding/decoding part.

In addition to that, we also changed the `Signature` field on `Token`
from a `string` to `[]byte` and this is also now populated with the
decoded form. This is also more consistent, because the other parts of
the JWT, mainly `Header` and `Claims` were already stored in decoded
form in `Token`. Only the signature was stored in base64 encoded form,
which was redundant with the information in the `Raw` field, which
contains the complete token as base64.

```go
type Token struct {
	Raw       string                 // Raw contains the raw token
	Method    SigningMethod          // Method is the signing method used or to be used
	Header    map[string]interface{} // Header is the first segment of the token in decoded form
	Claims    Claims                 // Claims is the second segment of the token in decoded form
	Signature []byte                 // Signature is the third segment of the token in decoded form
	Valid     bool                   // Valid specifies if the token is valid
}
```

Most (if not all) of these changes should not impact the normal usage of
this library. Only users directly accessing the `Signature` field as
well as developers of custom signing methods should be affected.

#### What's Changed

- Added GitHub Actions Markdown by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/260](https://togithub.com/golang-jwt/jwt/pull/260)
- Remove `StandardClaims` in favor of `RegisteredClaims` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[#&#8203;235](https://togithub.com/golang-jwt/jwt/issues/235)
- Adding more coverage by [@&#8203;oxisto](https://togithub.com/oxisto)
in [#&#8203;268](https://togithub.com/golang-jwt/jwt/issues/268)
- More consistent way of handling validation errors by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[#&#8203;274](https://togithub.com/golang-jwt/jwt/issues/274)
- New Validation API by [@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/236](https://togithub.com/golang-jwt/jwt/pull/236)
- `v5` Pre-Release by [@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/234](https://togithub.com/golang-jwt/jwt/pull/234)
- no need for string slice and call to strings.join by
[@&#8203;moneszarrugh](https://togithub.com/moneszarrugh) in
[https://github.com/golang-jwt/jwt/pull/115](https://togithub.com/golang-jwt/jwt/pull/115)
- Update MIGRATION_GUIDE.md by
[@&#8203;liam-verta](https://togithub.com/liam-verta) in
[https://github.com/golang-jwt/jwt/pull/289](https://togithub.com/golang-jwt/jwt/pull/289)
- Moving `DecodeSegement` to `Parser` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/278](https://togithub.com/golang-jwt/jwt/pull/278)
- Adjusting the error checking example by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/270](https://togithub.com/golang-jwt/jwt/pull/270)
- add documentation to hmac `Verify` & `Sign` to detail why string is
not an advisable input for key by
[@&#8203;dillonstreator](https://togithub.com/dillonstreator) in
[https://github.com/golang-jwt/jwt/pull/249](https://togithub.com/golang-jwt/jwt/pull/249)
- Add golangci-lint by [@&#8203;mfridman](https://togithub.com/mfridman)
in
[https://github.com/golang-jwt/jwt/pull/279](https://togithub.com/golang-jwt/jwt/pull/279)
- Added dependabot updates for GitHub actions by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/298](https://togithub.com/golang-jwt/jwt/pull/298)
- Bump actions/checkout from 2 to 3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/golang-jwt/jwt/pull/299](https://togithub.com/golang-jwt/jwt/pull/299)
- Bump actions/setup-go from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/golang-jwt/jwt/pull/300](https://togithub.com/golang-jwt/jwt/pull/300)
- Added coverage reporting by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/304](https://togithub.com/golang-jwt/jwt/pull/304)
- Last Documentation cleanups for `v5` release by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[https://github.com/golang-jwt/jwt/pull/291](https://togithub.com/golang-jwt/jwt/pull/291)
- enable jwt.ParsePublicKeyFromPEM to parse PKCS1 Public Key by
[@&#8203;twocs](https://togithub.com/twocs) in
[https://github.com/golang-jwt/jwt/pull/120](https://togithub.com/golang-jwt/jwt/pull/120)

#### New Contributors

- [@&#8203;moneszarrugh](https://togithub.com/moneszarrugh) made their
first contribution in
[https://github.com/golang-jwt/jwt/pull/115](https://togithub.com/golang-jwt/jwt/pull/115)
- [@&#8203;liam-verta](https://togithub.com/liam-verta) made their first
contribution in
[https://github.com/golang-jwt/jwt/pull/289](https://togithub.com/golang-jwt/jwt/pull/289)
- [@&#8203;dillonstreator](https://togithub.com/dillonstreator) made
their first contribution in
[https://github.com/golang-jwt/jwt/pull/249](https://togithub.com/golang-jwt/jwt/pull/249)
- [@&#8203;dependabot](https://togithub.com/dependabot) made their first
contribution in
[https://github.com/golang-jwt/jwt/pull/299](https://togithub.com/golang-jwt/jwt/pull/299)
- [@&#8203;twocs](https://togithub.com/twocs) made their first
contribution in
[https://github.com/golang-jwt/jwt/pull/120](https://togithub.com/golang-jwt/jwt/pull/120)

**Full Changelog**:
https://github.com/golang-jwt/jwt/compare/v4.5.0...v5.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/woodpecker-ci/woodpecker).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <ndev@web.de>
2023-09-13 09:01:01 +02:00
Sebastian P
07094558a8
fix: change config.config_data column type to longblob in mysql (#2434)
See
https://github.com/woodpecker-ci/woodpecker/pull/2418#discussion_r1320832841
for context.
2023-09-10 22:24:51 +02:00
Sebastian P
47b9dab016
Fix: change tasks.task_data column type to longblob in mysql (#2418)
Fix #2206 

Changes are copied and adapted from #1050
2023-09-10 13:33:48 +02:00
qwerty287
d04bb72e5e
Add repos list for admins (#2347) 2023-09-08 12:26:20 +02:00
Michalis Zampetakis
8a517a8596
Do not list archived repos for all forges (#2374)
Bitbucket seems that does not support repository archiving.

Resolves: https://github.com/woodpecker-ci/woodpecker/issues/2235

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-09-06 21:40:25 +02:00
Matheus Moraes
85e157bb10
fix(server/api/repo): Fix repair webhook host (#2372)
Fixes https://github.com/woodpecker-ci/woodpecker/issues/2371

Similar change to
https://github.com/woodpecker-ci/woodpecker/pull/1869/files#diff-3cd73db84155aa0447a17dadc8f50271d646fcf6132606cf2ab703cc7b80eb38R113
2023-09-06 12:17:23 +02:00
qwerty287
56b8ba151a
Delete repos/secrets on org deletion (#2367) 2023-09-02 15:00:13 +02:00
qwerty287
3e563ef198
Use API error helpers and improve response codes (#2366) 2023-09-02 13:31:10 +02:00
guangwu
287590acfb
Import packages only once (#2362)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-09-01 17:02:21 +02:00
qwerty287
aab7e73322
Execute make generate with new versions (#2365)
Fixes current swagger checks:
https://ci.woodpecker-ci.org/repos/3780/pipeline/7605/26
2023-09-01 16:44:55 +02:00
qwerty287
e847cbadfa
Check permissions on repo lookup (#2357)
There was no permission check when looking up repos so you were able to
get basic repo information even if you're not allowed to.

This uses `session.MustPull` (and set repo/perms before) to fix this.
2023-08-30 16:35:34 +02:00
qwerty287
5bd12aa646
Show that repo is disabled (#2340)
And allow to show badges for disabled repos

Fixes 3rd checkbox from
https://github.com/woodpecker-ci/woodpecker/discussions/2162#discussion-5498655

![Screenshot 2023-08-28 at 11-13-23
Woodpecker](https://github.com/woodpecker-ci/woodpecker/assets/80460567/d881f0c5-6225-4921-9d05-a26f27ad5365)
2023-08-28 18:57:44 +02:00
Anbraten
25225d4902
Update grpc generated code (#2339)
missed in #2173

---------
2023-08-28 18:00:52 +02:00
qwerty287
6f1f0e37ce
Fix org fetching (#2343) 2023-08-28 17:01:18 +02:00
qwerty287
479ced3b25
Add org list (#2338)
![Screenshot 2023-08-28 at 10-08-20
Woodpecker](https://github.com/woodpecker-ci/woodpecker/assets/80460567/e3248b05-7899-43ca-a0cf-4834eae078d8)
Closes #2307
2023-08-28 11:15:16 +02:00
qwerty287
7adfa6c2ba
Fix migration (#2319) 2023-08-22 17:37:29 +02:00
Pablo Ovelleiro Corral
cf9a4be128
Add missing return (#2316) 2023-08-22 09:47:29 +02:00
Anbraten
4de8cbec76
Rename grpc pipeline to workflow (#2173)
closes #1823

Co-authored-by: 6543 <6543@obermui.de>
2023-08-21 18:30:19 +02:00
qwerty287
81ead7cbf2
Support user secrets (#2126) 2023-08-21 15:04:12 +02:00
Pablo Ovelleiro Corral
09624aa286
Pass netrc data to external config service request (#2310)
Co-authored-by: Anbraten <anton@ju60.de>
2023-08-21 13:22:33 +02:00
Lauris BH
a58e3b9e06
Handle parsed hooks that should be ignored (#2243)
Currently it would fail with panic:

```
runtime error: invalid memory address or nil pointer dereference
...
/woodpecker/src/github.com/woodpecker-ci/woodpecker/server/forge/gitea/gitea.go:492 (0xdfb32e)
```
2023-08-18 14:25:29 +02:00
6543
a5ef372190
Move "skip ci" logic into global pipeline conditions (#2216)
... and make custom errors follow std err conventions

this fix a 500 response if the whole pipeline is filtered out
2023-08-17 15:52:43 +02:00
6543
c2448b1745
Restructure webhook parsing (#2221)
Co-authored-by: Anbraten <anton@ju60.de>
2023-08-16 16:15:44 +02:00
Anbraten
479e500b1b
Move hook and events-stream routes to use /api prefix (#2212)
- move hook and events-stream routes to use `/api` prefix
- rename build to pipeline
2023-08-16 02:42:37 +02:00
qwerty287
4d83ea0de8
Add SSH clone URL env var (#2198)
to improve https://github.com/woodpecker-ci/plugin-git/pull/75
2023-08-12 17:39:13 +02:00
qwerty287
8cdac56d8f
Check for correct license header (#2137) 2023-08-10 11:06:00 +02:00
qwerty287
6e0def58a1
Switch to upstream ttlcache (#2187)
We've been using https://github.com/lafriks/ttlcache but it's archived.
It does work with the upstream library too, so its better to use it.
2023-08-10 09:17:12 +02:00
6543
63d5c40afd
Deprecate "platform" filter in favour of "labels" (#2181)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-08-09 16:09:44 +02:00
6543
ada3659eb7
make EqualStringSlice to generic EqualSliceValues (#2179)
just a fly-by refactoring
2023-08-09 09:00:12 +02:00
6543
17ab945825
Fix 'add-orgs' migration (#2117)
close  #2096

~~blocked by https://gitea.com/xorm/xorm/pulls/2320~~
2023-08-08 00:16:50 +03:00
6543
d253f8cc30
Make sure we dont have hidden options for backend and pipeline compiler (#2123)
move options based on **os.Getenv** into flags

---------
*Sponsored by Kithara Software GmbH*
2023-08-07 21:13:26 +02:00