Commit Graph

232 Commits (v2)

Author SHA1 Message Date
René 8b9db059d7 Doc BodyParser: Add multipart form info about the file data 2025-01-23 08:32:43 +01:00
René 3729281a1e Doc BodyParser: Add multipart form info about the file data 2025-01-22 08:35:17 +01:00
René bfcf91dab8 fix template markdown 2024-08-30 17:22:07 +02:00
Giovanni Rivera ca935c3f8f
📚 Doc: Add detailed documentation for the templates guide (#3113)
* Organize and reword templates guide

* Add full example to templates guide

* Add advanced templating section to template guide

* Add template repo link and fix typo in Templates guide

- Add link to https://github.com/gofiber/template in Templates Guide
- Fix typo: missing period in info block about ctx.Render()

* Update docs/guide/templates.md

* Update docs/guide/templates.md

---------

Co-authored-by: RW <rene@gofiber.io>
2024-08-28 09:01:02 +02:00
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
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
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
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
René Werner 476e1ed9fe fix healthcheck.md 2024-01-05 14:36:18 +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
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
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 28be17f929.

* 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
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
RW 28be17f929
Revert "🐛 requestid.Config.ContextKey is interface{} (#2369)" (#2742)
This reverts commit d7b36cde
2023-11-27 14:35:49 +01:00
Jason McNeil 2374cad3cd
📄 docs: improve csrf docs (#2726)
* docs: improve csrf docs

- fix issues with `X-Csrf-Token` capitalization inconsistency.
- reduce redundancy and repetition.
- improve grammar.

* docs: update middleware description

* docs: within vs in

* docs: deleting tokens

* docs: MUST

* docs: add colon

* docs: all modern browsers

* docs: patterns

* docs: improve phrasing of pattern options
2023-11-16 12:34:31 +01:00
René Werner 3ab3d151c7 refresh docs for
🔥 Add support for application/problem+json #2704
2023-11-15 09:23:08 +01:00
Reid Hurlburt 9f082af045
🔥 Add support for application/problem+json (#2704)
🔥 Add support for custom JSON content headers
2023-11-13 15:18:05 +01:00
nickajacks1 cbcb1aec0a
feat: add support for parameters in content negotiation (#2678)
*  feat: add support for parameters in content negotiation

Attempts to approach the level of support offered by express,
but behavior may differ in unusual corner cases.
Some key behaviors from Express that are implemented:
 - If an offer does not have every parameter listed in the given Accept,
   it is rejected.
 - Parameters do not affect specificity.
 - In a given specificity, more parameters gives greater precedence
 - Parameters are unordered
 - Matching is case-insensitive
 - Surrounding quotes for parameter values are stripped
 - If an Accept type specifies a parameter more than once, the last
   value provided is taken.
 - Parameters after q are not processed.

https://www.rfc-editor.org/rfc/rfc9110#name-parameters

* doc: properly attribute reader.go for validHeaderFieldByte

* fix: remove underscores from fuzz test name

* test(forEachParameter): improve coverage

* doc: add comment clarifying RFC 9110 non-compliance for corner case
2023-11-07 08:25:23 +01:00
Moritz fe395b9850
📚 Doc: Add additional information as to why GetReqHeaders returns a map where the values are slices of strings (#2698)
* Update ctx.md

Added additional information to why GetReqHeaders returns a map where the values are slices of strings (instead of a single string as one might expect)

* Update ctx.md

added the same explanation to GetRespHeaders too
2023-11-01 21:42:57 +01:00
RW 4099ef87bb
Update routing.md
fix invalid regex constraint
2023-11-01 08:22:10 +01:00
Jason McNeil 4bf3695125
📄 docs: enhance csrf.md (#2692)
* docs: enhance csrf.md

* docs: simplify language

* docs: update csrf.md

* docs: delete token/session reminders

* docs: and ! or
2023-10-27 13:45:30 +02:00
René Werner 9347a86cdb 📗 Add example for response handling with fiber client 2023-10-24 08:35:50 +02:00
RW 6f0d34d39e
Update csrf.md 2023-10-16 14:31:28 +02:00
Jason McNeil 8c3916dbf4
Merge pull request from GHSA-94w9-97p3-p368
* feat: improved csrf with session support

* fix: double submit cookie

* feat: add warning cookie extractor without session

* feat: add warning CsrfFromCookie SameSite

* fix: use byes.Equal instead

* fix: Overriden CookieName KeyLookup cookie:<name>

* feat: Create helpers.go

* feat: use compareTokens (constant time compare)

* feat: validate cookie to prevent token injection

* refactor: clean up csrf.go

* docs: update comment about Double Submit Cookie

* docs: update docs for CSRF changes

* feat: add DeleteToken

* refactor: no else

* test: add more tests

* refactor: re-order tests

* docs: update safe methods RCF add note

* test: add CSRF_Cookie_Injection_Exploit

* feat: add SingleUseToken config

* test: check for new token

* docs: use warning

* fix: always register type Token

* feat: use UUIDv4

* test: swap in UUIDv4 here too

* fix: raw token injection

* fix: merege error

* feat: Sentinel errors

* chore: rename test

* fix: url parse

* test: add path to referer

* test: add expiration tests

* docs: add cookie prefix note

* docs: fix typo

* docs: add warning for refer checks

* test: add referer edge cases

And call ctx.Request.Reset() and
ctx.Response.Reset() before re-using ctx.
2023-10-16 09:06:30 +02:00
Javier Scappini d974cf3c99
Fix typo in requestid.md
Minor typo fix in requestid.md.
2023-10-13 11:37:06 +00:00
joey1123455 e70b2e28d6
Cookie parser (#2656)
* prep for branching

* feature: added a cookie parser and tests appropriate tests

*  feature: added a cookie parser and appropriate tests

* made correction to docs

* linted using gofumpt

* ctx_test linted, cookieParser schema added

* fix lint errors (Cookie parser #2656)

* removed extra lines, tested return values

---------

Co-authored-by: René Werner <rene.werner@verivox.com>
2023-10-12 10:44:15 +02:00
Jason McNeil b50d91d58e
Merge pull request from GHSA-94w9-97p3-p368
* feat: improved csrf with session support

* fix: double submit cookie

* feat: add warning cookie extractor without session

* feat: add warning CsrfFromCookie SameSite

* fix: use byes.Equal instead

* fix: Overriden CookieName KeyLookup cookie:<name>

* feat: Create helpers.go

* feat: use compareTokens (constant time compare)

* feat: validate cookie to prevent token injection

* refactor: clean up csrf.go

* docs: update comment about Double Submit Cookie

* docs: update docs for CSRF changes

* feat: add DeleteToken

* refactor: no else

* test: add more tests

* refactor: re-order tests

* docs: update safe methods RCF add note

* test: add CSRF_Cookie_Injection_Exploit

* feat: add SingleUseToken config

* test: check for new token

* docs: use warning

* fix: always register type Token

* feat: use UUIDv4

* test: swap in UUIDv4 here too
2023-10-11 14:41:42 +02:00
RW ada2d4affd
Update hooks.md 2023-10-09 08:58:49 +02:00
René Werner 59409f3841 improve sendFile documentation 2023-10-06 11:43:10 +02:00
René Werner 5171f6b505 improve compress middleware documentation 2023-10-05 09:00:11 +02:00
KaptinLin d00f0b8348
feat: add Reset method to Session struct in session middleware (#2654) 2023-10-02 15:19:35 +02:00
KaptinLin d86c257c89
feat: add Delete method to Store struct in session middleware (#2655)
*  feat: add Delete method to Store struct in session middleware

* ♻ refactor: enhance Delete method and test cases in session middleware
2023-10-02 15:19:18 +02:00
M. Efe Çetin a9447a5b49
ctx: change signatures of GetReqHeaders and GetRespHeaders (#2650)
* ctx: change signatures of GetReqHeaders and GetRespHeaders

* fix middlewares
2023-09-28 08:31:31 +02:00
Jimmy Li c0988de91e
📝 middleware: cors: update docs to better explain AllowOriginsFunc (#2652) 2023-09-28 08:28:35 +02:00
M. Efe Çetin e6d6fbe5a8
middleware: cors: allow disabling caching in preflight requests (#2649) 2023-09-27 15:06:24 +02:00
RW e547bea49e
Update cache.md 2023-09-20 09:14:58 +02:00
)`(-@_.+_^*__*^ 328411a06b
Replaced double quotes with backticks in all route parameter strings (#2591)
* 11-aryan

* Removed the backticks where no special characters is used

* added backticks to path parameters where special characters are escaped

* Replaced double quotes with backticks in all route parameter strings #2591

* Replaced double quotes with backticks in all route parameter strings #2591

---------

Co-authored-by: René Werner <rene@gofiber.io>
2023-09-04 05:40:44 +02:00
René Werner 5745dfe1ac add docs for dynamic routing 2023-08-27 14:29:17 +02:00
René Werner 57aef091c4 add docs for dynamic routing 2023-08-27 14:27:40 +02:00
Jian Lim 35797e6639
📝 Docs: update io/ioutil package to io package (#2589)
Deprecation of io/ioutil
2023-08-22 08:57:00 +02:00
M. Efe Çetin 1dea615ddf
🔥 add config to enable splitting by comma in parsers (#2560)
* 🔥 add config to enable splitting by comma in parsers

🔥 add config to enable splitting by comma in parsers

* optimize if statements, remove escape char support

optimize if statements, remove escape char support

* update
2023-08-21 09:44:02 +02:00