https://github.com/mevdschee/aspnetcookie
A Go package that can decode an ASP.net FormsAuthentication encrypted cookie.
https://github.com/mevdschee/aspnetcookie
Last synced: 10 months ago
JSON representation
A Go package that can decode an ASP.net FormsAuthentication encrypted cookie.
- Host: GitHub
- URL: https://github.com/mevdschee/aspnetcookie
- Owner: mevdschee
- License: mit
- Created: 2016-11-18T09:27:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-26T20:45:10.000Z (over 8 years ago)
- Last Synced: 2024-10-04T21:41:18.177Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/mevdschee/aspnetcookie)
[](https://coveralls.io/github/mevdschee/aspnetcookie?branch=master)
# aspnetcookie
A Go package that can decode and validate an ASP.net FormsAuthentication encrypted and signed cookie.
## Limitations
Currently only the following (Web.config) configuration is tested:
```
```
Only SHA1 based HMAC and AES encryption are currently supported.
## Usage
```
validationKey, _ := hex.DecodeString("2E502E08392C704E2234759EDA7A5940A8CE1C42C7964B8142778764CF0006C2")
decryptionKey, _ := hex.DecodeString("5226859B3CB262982B574093B29DAD9083030C93604C820F009D5192BDEC31F2")
codec := aspnetcookie.New("SHA1", validationKey, "AES", decryptionKey)
cookie, _ := codec.EncodeNew("maurits.vanderschee", 3600*24*365, true, "\"nothing\"", "/")
ticket, _ := codec.Decode(cookie)
```
where ticket is:
```
// FormsAuthenticationTicket holds:
type FormsAuthenticationTicket struct {
version byte
name string
issueDateUtc int64
expirationDateUtc int64
isPersistent bool
userData string
cookiePath string
}
```
## Links
see: https://referencesource.microsoft.com/#System.Web/Security/FormsAuthentication.cs