3726 Commits

Author SHA1 Message Date
Jason McNeil
6c9510df5a
docs: Improve ctx.Locals method description and example (#3030) 2024-06-11 08:53:43 +02:00
RW
6c3eb80aa9
Update csrf.md
fix broken csrf link
2024-04-19 12:35:20 +02:00
René
ef561694ba fix md syntax 2024-04-19 12:28:23 +02:00
RW
ab382cdd4a
Update release-drafter.yml 2024-04-07 20:34:00 +02:00
René
d0c8f8c82e Add a new benchmark that tests the ctx acquire and release flow
this will be used later to make differences with version 3 directly visible
2024-04-03 23:16:51 +02:00
René
f098e2bd9c Add a new benchmark that tests the ctx acquire and release flow
this will be used later to make differences with version 3 directly visible
2024-04-03 22:44:56 +02:00
René
96330a6c05 Add a new benchmark that tests the simple flow
this will be used later to make differences with version 3 directly visible
2024-04-03 16:17:40 +02:00
RW
fd811cf84a
prepare release v2.52.4 v2.52.4 2024-03-26 22:40:09 +01:00
Jason McNeil
a6f4c133bc
fix(middleware/cors): Vary header handling non-cors OPTIONS requests (#2939)
* fix(middleware/cors): Vary header handling non-cors OPTIONS requests

* chore(middleware/cors): Add Vary header for non-CORS OPTIONS requests comment
2024-03-26 22:22:42 +01:00
Jason McNeil
e574c0db52
fix(middleware/cors): CORS handling (#2937)
* fix(middleware/cors): CORS handling

* fix(middleware/cors): Vary header handling

* test(middleware/cors): Ensure Vary Headers checked
2024-03-26 21:57:42 +01:00
RW
43d5091967
Prepare release v2.52.3 v2.52.3 2024-03-25 20:26:29 +01:00
Jason McNeil
ba10e68d01
test(middleware/csrf): Fix Benchmark Tests (#2932)
* test(middleware/csrf): fix Benchmark_Middleware_CSRF_*

* fix(middleware/csrf): update refererMatchesHost()
2024-03-25 15:30:20 +01:00
Jason McNeil
1607d872d9
fix(middleware/cors): Categorize requests correctly (#2921)
* fix(middleware/cors): categorise requests correctly

* test(middleware/cors): improve test coverage for request types

* test(middleware/cors): Add subdomain matching tests

* test(middleware/cors): parallel tests for CORS headers based on request type

* test(middleware/cors): Add benchmark for CORS subdomain matching

* test(middleware/cors): cover additiona test cases

* refactor(middleware/cors): origin validation and normalization
2024-03-20 14:57:29 +01:00
Jason McNeil
1aac6f618b
fix(middleware/cors): Handling and wildcard subdomain matching (#2915)
* fix: allow origins check

Refactor CORS origin validation and normalization to trim leading or trailing whitespace in the cfg.AllowOrigins string [list]. URLs with whitespace inside the URL are invalid, so the normalizeOrigin will return false because url.Parse will fail, and the middleware will panic.

fixes #2882

* test: AllowOrigins with whitespace

* test(middleware/cors): add benchmarks

* chore: fix linter errors

* test(middleware/cors): use h() instead of app.Test()

* test(middleware/cors): add miltiple origins in Test_CORS_AllowOriginScheme

* chore: refactor validate and normalize

* test(cors/middleware): add more benchmarks

* fix(middleware/cors): handling and wildcard subdomain matching

docs(middleware/cors): add How it works and Security Considerations

* chore: grammar

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore: fix misspelling

* test(middleware/cors): combine Invalid_Origins tests

* refactor(middleware/cors): headers handling

* docs(middleware/cors): Update AllowOrigins description

* chore: merge

* perf(middleware/cors): optimize handler

* perf(middleware/cors): optimize handler

* chore(middleware/cors): ipdate origin handling logic

* chore(middleware/cors): fix header capitalization

* docs(middleware/cors): improve sercuity notes

* docs(middleware/cors): Improve security notes

* docs(middleware/cors): improve CORS overview

* docs(middleware/cors): fix ordering of how it works

* docs(middleware/cors): add additional info to How to works

* docs(middleware/cors): rm space

* docs(middleware/cors): add validation for AllowOrigins origins to overview

* docs(middleware/cors): update ExposeHeaders and MaxAge descriptions

* docs(middleware/cors): Add dynamic origin validation example

* docs(middleware/cors): Improve security notes and fix header capitalization

* docs(middleware/cors): configuration examples

* docs(middleware/cors): `"*"`

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2024-03-17 13:43:16 +01:00
René
d2b19e290d refactor(docs): deactivate docs sync for v2 2024-03-02 19:14:29 +01:00
René
68d90cd6b2 refactor(docs): deactivate docs sync for v2 2024-03-02 19:13:07 +01:00
RW
109e91a630
prepare release v2.52.2 v2.52.2 2024-03-02 18:56:50 +01:00
Jason McNeil
d456e7d82e
fix(middleware/cors): Validation of multiple Origins (#2883)
* fix: allow origins check

Refactor CORS origin validation and normalization to trim leading or trailing whitespace in the cfg.AllowOrigins string [list]. URLs with whitespace inside the URL are invalid, so the normalizeOrigin will return false because url.Parse will fail, and the middleware will panic.

fixes #2882

* test: AllowOrigins with whitespace

* test(middleware/cors): add benchmarks

* chore: fix linter errors

* test(middleware/cors): use h() instead of app.Test()

* test(middleware/cors): add miltiple origins in Test_CORS_AllowOriginScheme

* chore: refactor validate and normalize

* test(cors/middleware): add more benchmarks
2024-03-01 10:31:11 +01:00
René Werner
ddc6b231f8 fix sync-docs workflow 2024-02-21 21:54:55 +01:00
René Werner
0df0e0855d fix sync-docs workflow 2024-02-21 21:43:28 +01:00
René Werner
70f21d5f7e fix cors domain normalize v2.52.1 2024-02-21 21:18:56 +01:00
RW
f9fcb0297c
Update app.go
prepare release v2.52.1
2024-02-21 17:03:00 +01:00
Juan Calderon-Perez
f0cd3b44b0
Merge pull request from GHSA-fmg4-x8pw-hjhg
* Enforce Wildcard Origins with AllowCredentials check

* Expand unit-tests, fix issues with subdomains logic, update docs

* Update cors.md

* Added test using localhost, ipv4, and ipv6 address

* improve documentation markdown

---------

Co-authored-by: René Werner <rene@gofiber.io>
2024-02-21 14:47:33 +01:00
Lucas Lemos
5e30112d08
fix: healthcheck middleware not working with route group (#2863)
* fix: healthcheck middleware not working with route group

* perf: change verification method to improve perf

* Update healthcheck_test.go

* test: add not matching route test for strict routing

* add more test cases

* correct tests

* correct test helpers

* correct tests

* correct tests

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: René Werner <rene@gofiber.io>
2024-02-19 14:28:58 +01:00
Juan Calderon-Perez
cf54c257e9
Merge pull request #2867 from grivera64/v2
📚 Doc: Fix code snippet indentation in /docs/api/middleware/keyauth.md
2024-02-18 21:40:18 -05:00
Giovanni Rivera
a84a7cee7e
📚 Doc: Fix code snippet indentation in /docs/api/middleware/keyauth.md
Removes an an extra level of indentation in line 51 of
`keyauth.md` [here](https://github.com/gofiber/fiber/blob/v2/docs/api/middleware/keyauth.md?plain=1#L51)
2024-02-18 18:21:23 -08:00
RW
4e0f180fe3
Update routing.md 2024-02-08 08:18:26 +01:00
RW
56d2ec7bd0
Update ctx.md 2024-02-06 09:11:21 +01:00
René Werner
8325ed086c update queryParser config 2024-02-06 08:40:32 +01:00
Jongmin Kim
e524b73524
Fix default value to false in docs of QueryBool (#2811)
fix default value to false in docs of QueryBool
2024-01-28 18:28:47 +01:00
René Werner
7ba3137f2e configure workflows for V2 branch 2024-01-06 17:45:21 +01:00
René Werner
2e66937b4e configure workflows for V2 branch 2024-01-06 17:36:42 +01:00
René Werner
476e1ed9fe fix healthcheck.md v2.52.0 2024-01-05 14:36:18 +01:00
René Werner
89f551becc prepare release v2.52.0
- add more Parser tests
2024-01-05 14:02:59 +01:00
Lucas Lemos
6249bc48bc
feat: add liveness and readiness checks (#2509)
*  feat: add liveness and readiness checkers

* 📝 docs: add docs for liveness and readiness

*  feat: add options method for probe checkers

*  tests: add tests for liveness and readiness

* ♻️ refactor: change default endpoint values

* ♻️ refactor: change default value for liveness endpoint

* 📝 docs: add return status for liveness and readiness probes

* ♻️ refactor: change probechecker to middleware

* 📝 docs: move docs to middleware session

* ♻️ refactor: apply gofumpt formatting

* ♻️ refactor: remove unused parameter

* split config and apply a review

* apply reviews and add testcases

* add benchmark

* cleanup

* rename middleware

* fix linter

* Update docs and config values

* Revert change to IsReady

* Updates based on code review

* Update docs to match other middlewares

---------

Co-authored-by: Muhammed Efe Cetin <efectn@protonmail.com>
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
2024-01-03 18:13:58 +01:00
RW
38eb4bd238
♻️ logger/middleware colorize logger error message #2593 (#2773) 2023-12-23 08:31:58 +01:00
gilwo
d6c88764eb
🩹🚨 - fix for redirect with query params (#2748)
* redirect with query params did not work, fix it and add test for it

* redirect middleware - fix test typo
2023-12-22 16:18:04 +01:00
RW
c49faf9a8a
🐛 [Bug]: Adaptator + otelfiber issue #2641 (#2772) 2023-12-22 14:49:58 +01:00
Muhammad Kholid B
1fac52a42a
🩹 Fix: CORS middleware should use the defined AllowedOriginsFunc config when AllowedOrigins is empty (#2771) 2023-12-22 14:48:37 +01:00
RW
43fa236d99
Update hooks.md
fix wrong hooks signature
2023-12-19 13:27:10 +01:00
Bruno
dc2d2ef524
Changing default log output (#2730)
changing default log output

Closes #2729
2023-12-18 15:20:18 +01:00
dependabot[bot]
b0925dc454
build(deps): bump github/codeql-action from 2 to 3 (#2763)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-16 13:30:45 +03:00
dependabot[bot]
c3fed55744
build(deps): bump github.com/google/uuid from 1.4.0 to 1.5.0 (#2762)
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-13 15:53:13 +03:00
Mehmet Firat KOMURCU
090acbbc5d
📚 Update app.md for indentation (#2761)
Update app.md for indentation
2023-12-13 08:52:16 +01:00
Benjamin Grosse
b1850834a3
fix: don't constrain middlewares' context-keys to strings 🐛 (#2751)
* Revert "Revert "🐛 requestid.Config.ContextKey is interface{} (#2369)" (#2742)"

This reverts commit 28be17f929cfa7d3c27dd292fc3956f2f9882e22.

* fix: request ContextKey default value condition

Should check for `nil` since it is `any`.

* fix: don't constrain middlewares' context-keys to strings

`context` recommends using "unexported type" as context keys to avoid
collisions https://pkg.go.dev/github.com/gofiber/fiber/v2#Ctx.Locals.

The official go blog also recommends this https://go.dev/blog/context.

`fiber.Ctx.Locals(key any, value any)` correctly allows consumers to
use unexported types or e.g. strings.

But some fiber middlewares constrain their context-keys to `string` in
their "default config structs", making it impossible to use unexported
types.

This PR removes the `string` _constraint_ from all middlewares, allowing
to now use unexported types as per the official guidelines. However
the default value is still a string, so it's not a breaking change, and
anyone still using strings as context keys is not affected.
2023-12-12 14:55:29 +01:00
iRedMail
c441bdf2d0
🩹 middleware/logger/: log client IP address by default (#2755)
* middleware/logger: Log client IP address by default.

* Update doc.
2023-12-08 10:36:43 +01:00
dependabot[bot]
8aa88689ae
build(deps): bump actions/setup-go from 4 to 5 (#2754)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 15:14:33 +01:00
Jason McNeil
e4d7e84335
chore(encryptcookie)!: update default config (#2753)
* chore(encryptcookie)!: update default config

docs(encryptcookie): enhance documentation and examples

BREAKING CHANGE: removed the hardcoded "csrf_" from the Except.

* docs(encryptcookie): reads or modifies cookies

* chore(encryptcookie): csrf config example

* docs(encryptcookie): md table spacing
2023-12-07 08:39:41 +01:00
tokelo-12
a80b288592
Update CONTRIBUTING.md (#2752)
Grammar correction.
2023-12-05 15:21:03 +01:00
RW
9bcc7f3978
Update v3-changes.md 2023-12-03 10:20:29 +01:00