{"id":24662300,"url":"https://github.com/domain80/guardian","last_synced_at":"2025-03-21T07:25:57.203Z","repository":{"id":194145649,"uuid":"689827258","full_name":"domain80/guardian","owner":"domain80","description":"a session manager written in golang","archived":false,"fork":false,"pushed_at":"2024-01-01T16:21:39.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T04:13:42.127Z","etag":null,"topics":["go","golang","http","session","session-management"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/domain80.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-11T01:43:38.000Z","updated_at":"2023-09-12T16:00:39.000Z","dependencies_parsed_at":"2023-10-02T06:34:44.918Z","dependency_job_id":"3d5950de-b00a-4316-afb7-774534b8aa97","html_url":"https://github.com/domain80/guardian","commit_stats":null,"previous_names":["1jack80/guardian","ijack80/guardian","domain80/guardian"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domain80%2Fguardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domain80%2Fguardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domain80%2Fguardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domain80%2Fguardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/domain80","download_url":"https://codeload.github.com/domain80/guardian/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244754615,"owners_count":20504739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","http","session","session-management"],"created_at":"2025-01-26T04:13:49.270Z","updated_at":"2025-03-21T07:25:57.180Z","avatar_url":"https://github.com/domain80.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guardian: HTTP Session Management for Go\n\n## Introduction\n\nGuardian is a Go package that provides HTTP session management functionality.  \nIt allows you to create and manage user sessions in your Go web applications. With Guardian, you can easily store and retrieve session data, set session timeouts, and handle session-related tasks.\n\n## Features\n\n-   **In-Memory Session Store**: Guardian comes with an in-memory session store, making it easy to get started. You can also implement custom session stores if needed.\n\n-   **Session Lifecycle Management**: Guardian provides features like session expiration, renewal, and invalidation to ensure session data is secure and up-to-date.\n\n-   **Middleware Integration**: You can easily integrate Guardian into your HTTP handlers using middleware, making session management a seamless part of your application.\n\n-   **Customizable**: Guardian allows you to configure session timeouts, cookie settings, and more to fit your application's needs.\n\n## Installation\n\nGuardian can be installed using Go modules:\n\n```sh\n$ go get github.com/domain80/guardian\n```\n\n## Basic Usage\n\nHere's a basic example of how to use Guardian to manage sessions in your Go application:\n\n```go\npackage main\n\nimport (\n    \"net/http\"\n    \"github.com/domain80/guardian\"\n)\n\nfunc main() {\n    // Create a new instance of the Guardian session manager with an in-memory store.\n    store := guardian.NewInMemoryStore()\n    sessionManager := guardian.NewSessionManager(\"myapp\", store)\n\n    // Define your HTTP handlers.\n    http.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n        // Create a new session.\n        session := sessionManager.CreateSession()\n        session.Data[\"username\"] = \"user123\"\n        sessionManager.Store.Save(\u0026session)\n\n        // Use the session.\n        // ...\n\n        w.WriteHeader(http.StatusOK)\n    })\n\n    // Wrap your handlers with the Guardian middleware.\n    http.Handle(\"/protected\", sessionManager.SessionMiddleware(func(w http.ResponseWriter, r *http.Request) {\n        session := sessionManager.GetFromContext(r.Context())\n        // Access session data and perform actions.\n        // ...\n\n        w.WriteHeader(http.StatusOK)\n    }))\n\n    // Start your HTTP server.\n    http.ListenAndServe(\":8080\", nil)\n}\n```\n\n## Documentation\n\nFor detailed documentation and additional features, refer to the [Guardian documentation](https://github.com/domain80/guardian).\n\n## License\n\nGuardian is licensed under the MIT License. See the [LICENSE](https://github.com/domain80/guardian/blob/main/LICENSE) file for details.\n\n## Contributing\n\nWe welcome contributions! Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/domain80/guardian).\n\n## Acknowledgments\n\n-   Guardian was inspired by various Go session management packages most especially that of [Alex Edwards](https://github.com/alexedwards/scs/)\n    and the need to advance my go coding skills\n\n-   A special thanks goes to the OWASP and their [informative cheatsheet](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Session_Management_Cheat_Sheet.md)\n    which helped immensely with providing me with a better understanding\n    of how session managers work.\n\nDocumentation generated entirely by [chatGPT](chat.openai.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomain80%2Fguardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomain80%2Fguardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomain80%2Fguardian/lists"}