-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3bf395
commit 4876dd8
Showing
8 changed files
with
352 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,64 @@ | ||
# go-secure-sessions | ||
A new session module to replace gorilla/sessions. | ||
This go-secure-sessions is not dependant on any router | ||
This go-secure-sessions is not dependant on any router | ||
|
||
Uses AES-128, AES-192, or AES-256 to store cookie sessions. | ||
|
||
|
||
### Using go-secure-sessions | ||
|
||
```go | ||
|
||
import "github.com/GolangToolKits/go-secure-sessions" | ||
|
||
// securekey must be at least 16 char long | ||
// The key argument should be the AES key, | ||
// either 16, 24, or 32 bytes to select | ||
// AES-128, AES-192, or AES-256. | ||
var secretKey = "dsdfs6dfs61dssdfsdfdsdsfsdsdllsd" | ||
|
||
var cf ConfigOptions | ||
cf.maxAge = 3600 | ||
cf.path= "/" | ||
sessionManager, err := NewSessionManager(secretKey, cf) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
r, _ := http.NewRequest("POST", "/test/test1", nil) | ||
var w http.ResponseWriter | ||
|
||
// If a session cookie already exists in the request, it is loaded | ||
// Otherwise a completely new session is created with the name given | ||
session := sessionManager.NewSession(r, "new_test_sesstion") | ||
|
||
|
||
type SomeObject struct{ | ||
Id int | ||
Name string | ||
} | ||
|
||
obj := SomeObject{ | ||
Id: 1, | ||
Name: "test" | ||
} | ||
|
||
// needed to serialize and deserialize this object | ||
gob.Register(SomeObject{}) | ||
|
||
//set some session values | ||
session.Set("test1", "some test1 value") | ||
session.Set("test2", "some test2 value") | ||
session.Set("test3", obj) | ||
// save the session before quitting or the values will be lost | ||
// session is saved securily as a cookie in the user's browser | ||
err:= session.Save(w) | ||
if err != nil{ | ||
log.Println("Sesion not saved") | ||
} | ||
|
||
// Read a value out of the session | ||
v1:= session.Get("test1") | ||
|
||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,56 @@ | ||
mode: set | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:37.88,41.16 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:50.2,50.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:41.16,47.3 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:47.8,49.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:54.68,56.43 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:77.2,77.12 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:56.43,59.32 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:59.32,61.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:61.9,67.27 5 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:72.4,74.14 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:67.27,69.5 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:69.10,71.5 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:81.77,85.28 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:95.2,95.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:85.28,87.17 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:87.17,89.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:89.9,91.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:92.8,94.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:98.63,102.14 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:127.2,127.11 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:130.2,130.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:102.14,107.17 5 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:107.17,109.18 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:109.18,111.19 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:111.19,113.20 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:113.20,115.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:115.21,117.22 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:117.22,120.9 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:127.11,129.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:133.66,140.16 6 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:166.2,166.11 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:169.2,169.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:140.16,144.17 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:144.17,146.18 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:146.18,148.19 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:148.19,150.20 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:150.20,152.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:152.21,154.22 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:154.22,159.9 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:166.11,168.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:23.52,24.21 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:27.2,27.23 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:24.21,26.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:31.45,33.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:38.2,38.12 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:33.21,35.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:35.8,37.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:42.76,44.2 1 0 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:32.88,36.16 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:44.2,44.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:36.16,41.3 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:41.8,43.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:50.68,52.43 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:70.2,70.12 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:52.43,54.32 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:54.32,56.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:56.9,60.27 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:65.4,67.14 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:60.27,62.5 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:62.10,64.5 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:74.70,76.14 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:92.2,92.12 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:76.14,79.17 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:79.17,87.18 8 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:87.18,89.5 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:96.77,100.28 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:110.2,110.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:100.28,102.17 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:102.17,104.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:104.9,106.4 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:107.8,109.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:113.63,117.14 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:142.2,142.11 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:145.2,145.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:117.14,122.17 5 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:122.17,124.18 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:124.18,126.19 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:126.19,128.20 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:128.20,130.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:130.21,132.22 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:132.22,135.9 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:142.11,144.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:148.66,155.16 6 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:182.2,182.11 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:185.2,185.20 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:155.16,159.17 4 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:159.17,161.18 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:161.18,163.19 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:163.19,165.20 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:165.20,167.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:167.21,169.22 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:169.22,175.9 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/sessionManager.go:182.11,184.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:21.52,22.21 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:25.2,25.23 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:22.21,24.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:29.45,31.21 2 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:36.2,36.12 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:31.21,33.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:33.8,35.3 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:40.59,43.9 3 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:46.2,46.15 1 1 | ||
github.com/GolangToolKits/go-secure-sessions/cookieSession.go:43.9,45.3 1 1 |
Oops, something went wrong.