Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chekun/golaravelsession
Go Laravel Session
https://github.com/chekun/golaravelsession
golang laravel session
Last synced: 2 days ago
JSON representation
Go Laravel Session
- Host: GitHub
- URL: https://github.com/chekun/golaravelsession
- Owner: chekun
- License: mit
- Created: 2017-05-30T05:45:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-08T05:24:17.000Z (over 5 years ago)
- Last Synced: 2024-06-20T02:10:16.572Z (4 months ago)
- Topics: golang, laravel, session
- Language: Go
- Size: 6.84 KB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go Laravel Session
========================Basic Decrypt Laravel's SessionID and Read Session Data support for golang.
### Features
- Decrypt SessionID (now for the default `AES-256-CBC` cipher only)
- Read Session Data from php-serialized format### Purpose
- golang websocket app combined with laravel app (authorize user)
- other### Examples
- GetSessionID
```go
cookie := "eyJpdiI6IjVrTVVDSmlyb1FtN2NrbmlOTllOUkE9PSIsInZhbHVlIjoiUU9pbCtMTjhQQnQyamJ6ZE5qenVWanhuZktUcjBkOUVsWU5ibkhlWHJyc25DNnZYQlRrOWlFd01ObVJwam1yVUtNcGRUanV1aEJIWHBsYXNiZytNenc9PSIsIm1hYyI6ImMzYzVmMGE1NWY5ZjEzMzRjOTVkN2FlZGY2YzZhNDExOTVhZjUzMjYzZmE3OTE1ODIwYWYzNmY5ODQzYjIwOGEifQ=="
key := "base64:qsDvCdhT+JPXEBD3ys/XraOXVNpshsyElzJmtgnBqEI="sessionID, _ := GetSessionID(cookie, key)
fmt.Println(sessionID)
//produces: RYodG5AekDidQCVLvs4fQIRAPSwarZV26U4shNVX
```- ParseSessionData
this is just wrapper usage of package
[`github.com/yvasiyarov/php_session_decoder/php_serialize`](https://github.com/yvasiyarov/php_session_decoder/tree/master/php_serialize)```go
sessionData := `a:5:{s:6:"_token";s:40:"eE5gVNqGSn6wneCJAzhtTMulPFwvOfDyZRSoVStA";s:3:"url";a:0:{}s:9:"_previous";a:1:{s:3:"url";s:29:"https://test.dev";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:52:"login_admin_59ba36addc2b2f9401580f014c7f58ea4e30989d";i:1;}`
session, _ := ParseSessionData(sessionData)
fmt.Println(session["_token"].(string))
```