Commit graph

31 commits

Author SHA1 Message Date
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
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