Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key rotation with VerificationKeySet #344

Merged
merged 10 commits into from Sep 13, 2023
Merged

Key rotation with VerificationKeySet #344

merged 10 commits into from Sep 13, 2023

Conversation

mfridman
Copy link
Member

@mfridman mfridman commented Sep 9, 2023

I wanted to see what this looked like by taking #328 and then adding a PublicKeyset with a well-defined set of keys.

Most of this is recommendations from @oxisto and piggybacked on #328.


Update 2023-09-13

This PR introduced a "verification key" interface type to use as a type constraint:

type VerificationKey interface {
    crypto.PublicKey | []uint8
}

As well as a "verification key set" struct the parser asserts as the return from Keyfunc.

type VerificationKeySet struct {
    Keys []VerificationKey
}

Keys will be tried one by one until all keys are exhausted or a valid key is found and .Verify returns a nil error.

If all keys are tried and all fail, only the last error is returned, they are not joined. It is an error to supply a valid VerificationKeySet with no keys.

@mfridman
Copy link
Member Author

mfridman commented Sep 9, 2023

@oxisto can we tune coveralls threshold?

coverage/coveralls — Coverage decreased (-0.02%) to 86.147%

Maybe if we can set it to 1% or something more sane?

parser.go Outdated Show resolved Hide resolved
@oxisto
Copy link
Collaborator

oxisto commented Sep 10, 2023

@oxisto can we tune coveralls threshold?

coverage/coveralls — Coverage decreased (-0.02%) to 86.147%

Maybe if we can set it to 1% or something more sane?

Yeah -1 % or maybe -0.5% sounds reasonable
Update: I changed the coverall settings, should hopefully apply in the next CI run

Copy link
Collaborator

@oxisto oxisto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea very much. Some smaller naming issues we should work out beforehand.

parser.go Outdated Show resolved Hide resolved
parser.go Outdated Show resolved Hide resolved
token.go Outdated Show resolved Hide resolved
token.go Show resolved Hide resolved
token.go Outdated Show resolved Hide resolved
@schmidtw
Copy link

This is more clear than #328 .

@mfridman mfridman changed the title Key rotation with PublicKeyset Key rotation with VerificationKeySet Sep 11, 2023
@mfridman mfridman merged commit 1e76606 into main Sep 13, 2023
8 checks passed
@mfridman mfridman deleted the mf-key-rotation branch September 13, 2023 01:29
@oxisto oxisto mentioned this pull request Sep 13, 2023
10 tasks
renovate bot added a commit to woodpecker-ci/woodpecker that referenced this pull request Nov 13, 2023
[![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/v5](https://togithub.com/golang-jwt/jwt) |
require | minor | `v5.0.0` -> `v5.1.0` |
| golang.org/x/crypto | require | minor | `v0.14.0` -> `v0.15.0` |
| golang.org/x/net | require | minor | `v0.17.0` -> `v0.18.0` |
| golang.org/x/oauth2 | require | minor | `v0.13.0` -> `v0.14.0` |
| golang.org/x/term | require | minor | `v0.13.0` -> `v0.14.0` |

---

### Release Notes

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

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

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

#### What's Changed

- Using jwt's native `ErrInvalidType` instead of
`json.UnsupportedTypeError` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[golang-jwt/jwt#316
- Fix typos in comments and test names by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#317
- Format: add whitespaces, remove empty lines by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#319
- Refactor example: use io.ReadAll instead of io.Copy by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#320
- Refactor code by using switch instead of if-else by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#318
- A quick way to validate token string by
[@&#8203;dcalsky](https://togithub.com/dcalsky) in
[golang-jwt/jwt#302
- Refactor: remove unnecessary \[]byte conversion to string by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#330
- Refactor: compare strings with strings.EqualFold by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#329
- Avoid use of json.NewDecoder by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#313
- Update ParseUnverified godoc by
[@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) in
[golang-jwt/jwt#341
- Update ci workflows (add go1.21) by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#345
- Bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[golang-jwt/jwt#346
- Key rotation with VerificationKeySet by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#344
- Add explicit ClaimsValidator implementation check for custom claims by
[@&#8203;epelc](https://togithub.com/epelc) in
[golang-jwt/jwt#343
- feat: allow making exp claim required by
[@&#8203;tareksha](https://togithub.com/tareksha) in
[golang-jwt/jwt#351
- Add error handling to examples by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#312

#### New Contributors

- [@&#8203;alexandear](https://togithub.com/alexandear) made their first
contribution in
[golang-jwt/jwt#317
- [@&#8203;dcalsky](https://togithub.com/dcalsky) made their first
contribution in
[golang-jwt/jwt#302
- [@&#8203;craigpastro](https://togithub.com/craigpastro) made their
first contribution in
[golang-jwt/jwt#313
- [@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) made their
first contribution in
[golang-jwt/jwt#341
- [@&#8203;epelc](https://togithub.com/epelc) made their first
contribution in
[golang-jwt/jwt#343
- [@&#8203;tareksha](https://togithub.com/tareksha) made their first
contribution in
[golang-jwt/jwt#351

**Full Changelog**:
golang-jwt/jwt@v5.0.0...v5.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge -
"before 4am" (UTC).

🚦 **Automerge**: Enabled.

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

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
nono added a commit to cozy/cozy-stack that referenced this pull request Nov 20, 2023
[![Mend Renovate logo
banner](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/v5](https://togithub.com/golang-jwt/jwt) |
require | minor | `v5.0.0` -> `v5.1.0` |

---

### Release Notes

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

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

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

#### What's Changed

- Using jwt's native `ErrInvalidType` instead of
`json.UnsupportedTypeError` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[golang-jwt/jwt#316
- Fix typos in comments and test names by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#317
- Format: add whitespaces, remove empty lines by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#319
- Refactor example: use io.ReadAll instead of io.Copy by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#320
- Refactor code by using switch instead of if-else by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#318
- A quick way to validate token string by
[@&#8203;dcalsky](https://togithub.com/dcalsky) in
[golang-jwt/jwt#302
- Refactor: remove unnecessary \[]byte conversion to string by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#330
- Refactor: compare strings with strings.EqualFold by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#329
- Avoid use of json.NewDecoder by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#313
- Update ParseUnverified godoc by
[@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) in
[golang-jwt/jwt#341
- Update ci workflows (add go1.21) by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#345
- Bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[golang-jwt/jwt#346
- Key rotation with VerificationKeySet by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#344
- Add explicit ClaimsValidator implementation check for custom claims by
[@&#8203;epelc](https://togithub.com/epelc) in
[golang-jwt/jwt#343
- feat: allow making exp claim required by
[@&#8203;tareksha](https://togithub.com/tareksha) in
[golang-jwt/jwt#351
- Add error handling to examples by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#312

#### New Contributors

- [@&#8203;alexandear](https://togithub.com/alexandear) made their first
contribution in
[golang-jwt/jwt#317
- [@&#8203;dcalsky](https://togithub.com/dcalsky) made their first
contribution in
[golang-jwt/jwt#302
- [@&#8203;craigpastro](https://togithub.com/craigpastro) made their
first contribution in
[golang-jwt/jwt#313
- [@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) made their
first contribution in
[golang-jwt/jwt#341
- [@&#8203;epelc](https://togithub.com/epelc) made their first
contribution in
[golang-jwt/jwt#343
- [@&#8203;tareksha](https://togithub.com/tareksha) made their first
contribution in
[golang-jwt/jwt#351

**Full Changelog**:
golang-jwt/jwt@v5.0.0...v5.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone
Europe/Paris, 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/cozy/cozy-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->
github-merge-queue bot pushed a commit to infratographer/x that referenced this pull request Apr 2, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/golang-jwt/jwt/v5](https://togithub.com/golang-jwt/jwt) |
`v5.0.0` -> `v5.2.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.0.0/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.0.0/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

[Compare
Source](https://togithub.com/golang-jwt/jwt/compare/v5.2.0...v5.2.1)

#### What's Changed

- chore: remove unnecessary conversions from tests by
[@&#8203;estensen](https://togithub.com/estensen) in
[golang-jwt/jwt#370
- Trivial: Typo fix for ECDSA error message by
[@&#8203;tjs-cinemo](https://togithub.com/tjs-cinemo) in
[golang-jwt/jwt#373
- Fix incorrect error return by
[@&#8203;ss49919201](https://togithub.com/ss49919201) in
[golang-jwt/jwt#371

#### New Contributors

- [@&#8203;tjs-cinemo](https://togithub.com/tjs-cinemo) made their first
contribution in
[golang-jwt/jwt#373
- [@&#8203;ss49919201](https://togithub.com/ss49919201) made their first
contribution in
[golang-jwt/jwt#371

**Full Changelog**:
golang-jwt/jwt@v5.2.0...v5.2.1

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

[Compare
Source](https://togithub.com/golang-jwt/jwt/compare/v5.1.0...v5.2.0)

#### What's Changed

- Exported `NewValidator` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[golang-jwt/jwt#349
- Improve ErrInvalidKeyType error messages by
[@&#8203;Laurin-Notemann](https://togithub.com/Laurin-Notemann) in
[golang-jwt/jwt#361
- Update MIGRATION_GUIDE.md by
[@&#8203;jbarham](https://togithub.com/jbarham) in
[golang-jwt/jwt#363

#### New Contributors

- [@&#8203;Laurin-Notemann](https://togithub.com/Laurin-Notemann) made
their first contribution in
[golang-jwt/jwt#361
- [@&#8203;jbarham](https://togithub.com/jbarham) made their first
contribution in
[golang-jwt/jwt#363

**Full Changelog**:
golang-jwt/jwt@v5.1.0...v5.2.0

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

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

#### What's Changed

- Using jwt's native `ErrInvalidType` instead of
`json.UnsupportedTypeError` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[golang-jwt/jwt#316
- Fix typos in comments and test names by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#317
- Format: add whitespaces, remove empty lines by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#319
- Refactor example: use io.ReadAll instead of io.Copy by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#320
- Refactor code by using switch instead of if-else by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#318
- A quick way to validate token string by
[@&#8203;dcalsky](https://togithub.com/dcalsky) in
[golang-jwt/jwt#302
- Refactor: remove unnecessary \[]byte conversion to string by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#330
- Refactor: compare strings with strings.EqualFold by
[@&#8203;alexandear](https://togithub.com/alexandear) in
[golang-jwt/jwt#329
- Avoid use of json.NewDecoder by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#313
- Update ParseUnverified godoc by
[@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) in
[golang-jwt/jwt#341
- Update ci workflows (add go1.21) by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#345
- Bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[golang-jwt/jwt#346
- Key rotation with VerificationKeySet by
[@&#8203;mfridman](https://togithub.com/mfridman) in
[golang-jwt/jwt#344
- Add explicit ClaimsValidator implementation check for custom claims by
[@&#8203;epelc](https://togithub.com/epelc) in
[golang-jwt/jwt#343
- feat: allow making exp claim required by
[@&#8203;tareksha](https://togithub.com/tareksha) in
[golang-jwt/jwt#351
- Add error handling to examples by
[@&#8203;craigpastro](https://togithub.com/craigpastro) in
[golang-jwt/jwt#312

#### New Contributors

- [@&#8203;alexandear](https://togithub.com/alexandear) made their first
contribution in
[golang-jwt/jwt#317
- [@&#8203;dcalsky](https://togithub.com/dcalsky) made their first
contribution in
[golang-jwt/jwt#302
- [@&#8203;craigpastro](https://togithub.com/craigpastro) made their
first contribution in
[golang-jwt/jwt#313
- [@&#8203;duhaesbaert](https://togithub.com/duhaesbaert) made their
first contribution in
[golang-jwt/jwt#341
- [@&#8203;epelc](https://togithub.com/epelc) made their first
contribution in
[golang-jwt/jwt#343
- [@&#8203;tareksha](https://togithub.com/tareksha) made their first
contribution in
[golang-jwt/jwt#351

**Full Changelog**:
golang-jwt/jwt@v5.0.0...v5.1.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/infratographer/x).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants