File tree Expand file tree Collapse file tree 5 files changed +47
-2
lines changed Expand file tree Collapse file tree 5 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 11# backend environment configs
22app :
3+ name : laclm
34 version : v1.1
4- debug_mode : true
5+ debug_mode : true
6+ session_timeout : 24
57
68# backend server deployment configs
79server :
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ type App struct {
55 Name string `yaml:"name,omitempty"`
66 Version string `yaml:"version,omitempty"`
77 DebugMode bool `yaml:"debug_mode,omitempty"`
8+ SessionTimeout int `yaml:"session_timeout,omitempty"`
89}
910
1011/* normalization function */
@@ -22,5 +23,9 @@ func (a *App) Normalize() error {
2223 we want production to be true
2324 */
2425
26+ if a .SessionTimeout == 0 {
27+ a .SessionTimeout = 24
28+ }
29+
2530 return nil
2631}
Original file line number Diff line number Diff line change 55 "net/http"
66
77 "go.uber.org/zap"
8- // "github.com/PythonHacker24/linux-acl-management-backend/internal/models"
98)
109
1110/* health handler provides status check on the backend server */
Original file line number Diff line number Diff line change 1+ package session
2+
3+ import (
4+ "container/list"
5+ "sync"
6+ "time"
7+ )
8+
9+ /* session struct for a user */
10+ type Session struct {
11+ Username string
12+ CurrentWorkingDir string
13+ Expiry time.Time
14+ Timer * time.Timer
15+ TransactionQueue * list.List
16+ Mutex sync.Mutex
17+ }
Original file line number Diff line number Diff line change 11package session
22
3+ import (
4+ "container/list"
5+ "time"
6+
7+ "github.com/PythonHacker24/linux-acl-management-backend/config"
8+ )
9+
10+ /* for creating a session for user */
311func CreateSession (username string ) {
12+ session := Session {
13+ Username : username ,
14+ Expiry : time .Now ().Add (time .Duration (config .BackendConfig .AppInfo .SessionTimeout ) * time .Hour ),
15+ Timer : time .AfterFunc (time .Duration (config .BackendConfig .AppInfo .SessionTimeout )* time .Hour ,
16+ func () { ExpireSession (username ) },
17+ ),
18+ TransactionQueue : list .New (),
19+ CurrentWorkingDir : "." ,
20+ }
21+
22+ }
23+
24+ /* for expiring a session */
25+ func ExpireSession (username string ) {
426
527}
You can’t perform that action at this time.
0 commit comments