aboutsummaryrefslogtreecommitdiff
path: root/lib/paseto
AgeCommit message (Collapse)Author
11 dayspaseto/v4: realign struct in testShulhan
This fix the following error detected by gocheck, public_mode_test.go:45:16: struct with 288 pointer bytes could be 264
14 dayspaseto/v4: allow empty Footer and empty data in PayloadShulhan
If the footer is empty then the message will be unpacked with its own public key, instead of sender public key.
2026-03-31lib/paseto: move [Message.Unpack] to [v4.UnpackPublicToken]Shulhan
Unpacking v4 public protocol on parent package seems wrong. Only v4 package should know how to unpack it regarding the available fields in the Message.
2026-03-30lib/paseto: update v4 package doc and mark v2 as deprecatedShulhan
The paseto/v4 now can replace the previous paseto/v2 package.
2026-03-30lib/paseto: make the DriftSeconds changeableShulhan
This is to make user can increases or decreases the leeway during Payload Validate.
2026-03-30lib/paseto: rename the field Public and Private in PeerShulhan
2026-03-30lib/paseto: add unit tests for Payload and Message typesShulhan
2026-03-30paseto/v4: embed the Peer inside the PublicModeShulhan
This provides simple operation when working with Pack and Unpack.
2026-03-30paseto/v4: improve examples by splitting example and packageShulhan
By not using the same package name in example, we can see how the package actually used in real code. For instance, we can know that constant publicHeader should be exported so it could be used by Unpack method.
2026-03-30lib/paseto: predefines errors variablesShulhan
Instead of fixed strings, predefined the error variables so the caller can check the actual error.
2026-03-30paseto/v4: implements API to Pack and Unpack Message for PublicModeShulhan
The Pack method returns the signed [paseto.Message] as public token. The token then verified and decoded into Message using the Unpack method.
2026-03-30lib/paseto: store the time as Unix epoch inside PayloadShulhan
Previously, we use time.Time to store the value for ExpiredAt, NotBefore, and IssuedAt. Even thought this is allowed (see RFC 7519 section 2, NumericDate) but it is not a standard practices. This changes them to store Unix epoch with int64.
2026-03-29lib/paseto: move message, payload, footer, and key type from v2Shulhan
The [v2/PublicToken] has been moved and renamed as [paseto.Message]. The Data field in the Message is removed since its duplicate with [Payload.Data]. The [v2/JSONToken] has been moved and renamed as [paseto.Payload]. In the [Payload.Validate] method, we remove the validation for IssuedAt field, since its usage is to store the time the token is created. The Data field type in the Payload changes from string to any. The [v2/JSONFooter] has been moved and renamed as [paseto.Footer]. The type of Data field in Footer changes from map[string]any to any. The KID field in the Footer has been renamed to PeerID along with its json identifer. The [v2/Key] has been moved and renamed as [paseto.Peer].
2026-03-29paseto/v4: implements public protocol for paseto version 4Shulhan
paseto/v4 provides a simple, ready to use, opinionated implementation of Platform-Agnostic SEcurity TOkens (PASETO) version 4 as defined in [paseto-v4]. The public protocol contains method to sign and verify the message into/from paseto token. [paseto-v4]: https://github.com/paseto-standard/paseto-spec/blob/master/docs/01-Protocol-Versions/Version4.md
2026-03-29paseto/v4: implements local protocol for paseto version 4Shulhan
paseto/v4 provides a simple, ready to use, opinionated implementation of Platform-Agnostic SEcurity TOkens (PASETO) version 4 as defined in [paseto-v4]. [paseto-v4]: https://github.com/paseto-standard/paseto-spec/blob/master/docs/01-Protocol-Versions/Version4.md
2026-03-28lib/paseto: move implementation to sub directory "v2"Shulhan
There are new versions of paseto standard: version 3 and version 4. To minimize conflicts in the future, we move the old implementation of paseto v2 to sub directory "v2" with package name "pasetov2". The paseto package now left with common functions, like creating pre-authentication encoding (PAE).
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2025-01-23all: replace "interface{}" with "any"Shulhan
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-09-11lib/paseto: add missing comment to exported typeShulhan
2023-09-11lib/paseto: realign struct for better size allocationShulhan
The realignment reduce the cost of the following struct, * JSONFooter: from 24 to 16 bytes (-8) * Key: from 72 to 56 bytes (-16) * keys: from 16 to 8 bytes (-8) * struct in TestEncrypt: from 88 to 80 bytes (-8) * structtest in TestSign: from 72 to 64 bytes (-8) * PublicMode: from 80 to 64 bytes (-16) * struct in TestPublicMode_UnpackHTTPRequest: from 56 to 48 bytes (-8) * PublicToken: from 152 to 136 bytes (-16)
2022-09-21lib/paseto: reformat the documentationShulhan
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2021-04-22paseto: replace le64() function with binary.Write()Shulhan
The le64() return the string representation of uint64 in little endian, which is basically binary.Write with parameter output buffer, LittleEndian, and input value.
2021-03-14all: refactoring the test.Assert and test.AssertBench signatureShulhan
Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench.
2020-11-15paseto: add unit test to validate JSON tokenShulhan
2020-10-21paseto: add 5 seconds time drift when validating JSONTokenShulhan
This changes permit 5 seconds differents on IssuedAt and NotBefore fields.
2020-10-08paseto: fix linter warningsShulhan
Remove unused constant "dateTimeLayout", check for error in call to AddPeer method in test and example, and suppress govet warning on le64().
2020-09-21paseto: change the Unpack return type to PublicTokenShulhan
Previously, UnpackHTTPRequest and Unpack methods return the data inside the token and footer. This changes, return the unpacked token as a whole, include the JSON token, the data inside JSON token, and the JSON footer. In this way, user can do additional process to the request token that they receive, for example, to log the request.
2020-09-16paseto: handle token request under 1 secondShulhan
If token generated and received under 1 second, the JSONToken.Validate() method will return with error because the IssuedAt and NotBefore will be equal with current time.
2020-09-15paseto: round the time to second to prevent sub-second precisionShulhan
Without rounding it will marshal the time value into, 2020-09-15T11:55:50.847276+07:00 This changes, round current time values to second so we can get value 2020-09-15T11:55:50+07:00
2020-09-14paseto: use byte as parameter for calculating little-endianShulhan
The spec said that the input is 64bit unsigned integer, but the PHP implementation does not match with the generated string. Since the input "n" will not greater than 3 and it bitmasked with 255, therefore the input should be byte instead of int64.
2020-09-09paseto: check for empty key ID and private key on NewPublicModeShulhan
2020-09-09paseto: add method to unpack token from HTTP requestShulhan
2020-09-09paseto: implement strict JSON token validationShulhan
* The Issuer field must equal to peer.ID * The Audience field must equal to our.ID, * If peer.AllowedSubjects is not empty, the Subject value must be in one of them, * The current time must be after IssuedAt field, * The current time must after NotBefore "nbf" field, * The current time must before ExpiredAt field.
2020-09-09paseto: new package for working with pasetoShulhan
Package paseto provide the opionated implementation of Platform-Agnostic SEcurity TOkens (PASETOs) as defined in draft of RFC 01 [1]. This implementation only support PASETO Protocol v2. This library focus on how to sign and verify data, everything else is handled and filled automatically. [1] https://github.com/paragonie/paseto/blob/master/docs/RFC/draft-paragon-paseto-rfc-01.txt