Commit graph

38 commits

Author SHA1 Message Date
Hank Shen
a9590b4584 Merge branch 'main' of github.com:/gorilla/securecookie 2023-10-09 12:42:42 +08:00
Corey Daley
22eae5c820
Update go version & add verification/testing tools (#81)
<!--
For Work In Progress Pull Requests, please use the Draft PR feature,
see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for
further details.

     For a timely review/response, please avoid force-pushing additional
     commits if your PR already received reviews or comments.

     Before submitting a Pull Request, please ensure that you have:
- 📖 Read the Contributing guide:
https://github.com/gorilla/.github/blob/main/CONTRIBUTING.md
- 📖 Read the Code of Conduct:
https://github.com/gorilla/.github/blob/main/CODE_OF_CONDUCT.md

     - Provide tests for your changes.
     - Use descriptive commit messages.
	 - Comment your code where appropriate.
	 - Squash your commits
     - Update any related documentation.

     - Add gorilla/pull-request-reviewers as a Reviewer
-->

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [x] Optimization
- [ ] Documentation Update

## Description

## Related Tickets & Documents

<!--
For pull requests that relate or close an issue, please include them
below. We like to follow [Github's guidance on linking issues to pull
requests](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).

For example having the text: "closes #1234" would connect the current
pull
request to issue 1234.  And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #

## Added/updated tests?

- [ ] Yes
- [ ] No, and this is why: _please replace this line with details on why
tests
      have not been included_
- [ ] I need help with writing tests

## Run verifications and test

- [ ] `make verify` is passing
- [ ] `make test` is passing
2023-07-31 15:18:18 -04:00
vvvvv
4ce52525b6
docs: changed deprecated goo.gl links to their unshortened variant (#77)
Unshortened the links in the docs because 
1. goo.gl is a deprecated service 
2. being able to see the actual link is more verbose thus more useful
inside of docs

Co-authored-by: Corey Daley <cdaley@redhat.com>
2023-07-29 15:00:07 -04:00
Filippo Valsorda
86450627d8 doc: correct a reference to block size that was meant to be key size (#64)
The AES block size is always the same, it's the key size that selects AES-128, AES-192, or AES-256.
2019-07-06 20:38:17 -07:00
Matt Silverlock
11123820fb [docs] Add note RE: persistence to GenerateRandomKey 2018-09-13 11:41:34 -07:00
Wesley Bitter
b009e17e9c [bugfix] check for an empty hashKey (#52)
this scenario might occur when converting from an empty string to
byte slice, such as when reading from a configuration file.
2018-05-18 08:25:24 -07:00
Wenhui Shen
4eede49ef7 update 2017-07-22 11:24:17 +08:00
Wenhui Shen
deb9be6946 Decode: 支持传入临时参数 maxAge 2017-07-22 11:11:58 +08:00
Craig Peterson
fa5329f913 [bugfix] Fix NopDecoder
* Fixes #41
2016-10-03 06:16:01 +01:00
Matt Silverlock
6ac16e3b5c [feature] NopEncoder: accept/return []byte.
- [docs] Update doc.go for golint.
2016-03-30 21:13:44 -07:00
Matt Silverlock
9479394b87 Reverts d8773d3 - backports len check for subtle.ConstantTimeCompare. 2015-08-20 16:26:03 +08:00
Matt Silverlock
6d727f0c85 Added note re: using GenerateRandomKey() not persisting keys. 2015-08-08 19:19:02 +08:00
Matt Silverlock
7029a2efc7 Improved warning around GenerateRandomKey. 2015-08-08 19:16:04 +08:00
Matt Silverlock
84828075d0 Improved documentation for CodecsFromPairs.
- Partially addresses https://github.com/gorilla/sessions/issues/48
- Downstream store packages will need to perform the type assertion in their code
- Elected to document this and fix stores rather than add a function to the
  public API.
2015-08-06 15:26:37 +08:00
Keunwoo Lee
8cd2140311 Move error type assertions to test file.
Per elithrar comment on PR 28:
https://github.com/gorilla/securecookie/pull/28#discussion_r35059831
2015-07-27 10:27:54 -07:00
Keunwoo Lee
ba5d1f998d Rename errorImpl -> cookieError
Per elithrar comment on PR 28:
https://github.com/gorilla/securecookie/pull/28#discussion_r35059597
2015-07-27 10:26:56 -07:00
Keunwoo Lee
9f0025d371 Make errors more distinguishable
Prior to this commit, this library raised errors either mostly using
errors.New() or directly passing through error values from underlying
libraries.  This made it difficult for clients to respond correctly to
the errors that were returned.

This becomes particularly problematic when securecookie is used together
with gorilla/sessions.  From an operations standpoint, you often want to
log different errors when the client simply provides an invalid auth
cookie, versus an I/O error fetching data from the session store.  The
former probably indicates an expired timestamp or similar client error;
the latter indicates a possible failure in a backend database.

This commit introduces a public Error interface, which is now returned
consistently on all errors, and can be used to distinguish between
implementation errors (IsUsage() and IsInternal()) and failed validation
of user input (IsDecode()).

See also discussion on pull requests #9 and #24:
https://github.com/gorilla/securecookie/pull/9
https://github.com/gorilla/securecookie/pull/24

Some interface comments on other API functions have been clarified and
updated to harmonize with the new error interfaces.
2015-07-20 15:00:22 -07:00
Matt Silverlock
b002d4848c Merge branch 'json-encoder' of github.com:elithrar/securecookie into json-encoder 2015-05-20 20:56:22 +00:00
Matt Silverlock
3c76054b69 Added a JSON encoder/decoder to securecookie.
A new "Serializer" interface with serialize/deserialize methods allows
custom encoders to be specified. encoding/gob remains the default for
compatibility/ease-of-use reasons, but the (often faster) encoding/json
is now an option.

Fixed typo - TestEncription => TestEncryption
2015-05-20 20:49:45 +00:00
Matt Silverlock
978e3ebada Added a JSON encoder/decoder to securecookie.
A new "Encoder" interface with serialize/deserialize methods allows
custom encoders to be specified. encoding/gob remains the default for
compatibility/ease-of-use reasons, but the (often faster) encoding/json
is now an option.
2015-05-16 17:50:49 +00:00
Kamil Kisiel
ab638a3cc2 Revert "Improve Decode against timing attacks"
This reverts commit 1be1b717b7.
2015-03-27 08:31:10 -07:00
Kamil Kisiel
3609df1fc5 Revert "Commenting retErr and setErr in Decode"
This reverts commit c7a729999d.
2015-03-27 08:31:09 -07:00
Kamil Kisiel
5d52df3629 Revert "A few more comments on decoding."
This reverts commit a54a6f264e.
2015-03-27 08:31:06 -07:00
Kamil Kisiel
a54a6f264e A few more comments on decoding. 2015-03-17 16:36:01 -07:00
Kamil Kisiel
1dea542d12 Merge pull request #16 from elithrar/patch-1
Removed redundant calls to len()
2015-03-17 16:33:49 -07:00
Matt Silverlock
d8773d3e66 Removed redundant calls to len()
subtle.ConstantTimeCompare already undertakes a length check internally.
2015-03-18 07:06:26 +08:00
Abdülhamit Yilmaz
c7a729999d Commenting retErr and setErr in Decode 2015-03-17 23:33:39 +01:00
Abdülhamit Yilmaz
1be1b717b7 Improve Decode against timing attacks 2015-03-17 20:33:51 +01:00
Abdülhamit Yilmaz
5ce09b9e8f Omit unnecessary elses
See http://golang.org/doc/effective_go.html#else
2015-03-17 19:25:18 +01:00
Kamil Kisiel
5f171f4232 Fix broken error message on invalid MAC.
Fixes #13.
2015-02-02 22:33:18 -08:00
Dominik Honnef
0ff019e2d6 say that we create a key of a certain length, not strength 2014-11-20 16:05:54 +01:00
Mahmud Ridwan
2cceedbcce Expose ErrMacInvalid; fixes gorilla/securecookie#6 2014-04-09 09:50:10 +06:00
Kamil Kisiel
6e2523a6cb Add travis.yml 2013-11-30 13:25:48 -08:00
Kamil Kisiel
155134204c Better errors for {En,De}codeMulti. 2013-10-17 10:33:57 -07:00
John Downey
d77f52d17e Fix description for Encode 2012-12-31 23:49:49 -06:00
moraes
74772485ec Use the same MultiError version from the App Engine SDK. 2012-10-13 14:05:18 -03:00
moraes
aaee2300ed Better errors for EncodeMulti and DecodeMulti. Closes #1. 2012-10-13 04:34:19 -03:00
moraes
f34e8230f6 Initial files. 2012-10-03 01:53:51 -03:00