{"id":24130437,"url":"https://github.com/babyblue94520/sync-session","last_synced_at":"2026-06-13T10:31:48.226Z","repository":{"id":57732542,"uuid":"381970119","full_name":"babyblue94520/sync-session","owner":"babyblue94520","description":"High performance session management","archived":false,"fork":false,"pushed_at":"2025-12-04T13:32:58.000Z","size":169,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-07T21:45:55.041Z","etag":null,"topics":["distributed-session","session","session-management"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babyblue94520.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":"2021-07-01T08:55:31.000Z","updated_at":"2025-12-04T13:13:14.000Z","dependencies_parsed_at":"2023-11-28T04:48:24.752Z","dependency_job_id":null,"html_url":"https://github.com/babyblue94520/sync-session","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/babyblue94520/sync-session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babyblue94520%2Fsync-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babyblue94520%2Fsync-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babyblue94520%2Fsync-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babyblue94520%2Fsync-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babyblue94520","download_url":"https://codeload.github.com/babyblue94520/sync-session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babyblue94520%2Fsync-session/sbom","scorecard":{"id":222424,"data":{"date":"2025-08-11","repo":{"name":"github.com/babyblue94520/sync-session","commit":"518de3dc01880ed9b01208035c41d6286f7ddb0b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: .mvn/wrapper/maven-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'release/2.0.0'","Warn: branch protection not enabled for branch 'release/1.2.0'","Warn: branch protection not enabled for branch '1.1.0'","Warn: branch protection not enabled for branch '1.0.0'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"33 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-vmq6-5m68-f53m","Warn: Project is vulnerable to: GHSA-6v67-2wr5-gvf4","Warn: Project is vulnerable to: GHSA-pr98-23f8-jwxv","Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-27hp-xhwr-wr2m","Warn: Project is vulnerable to: GHSA-5j33-cvvr-w245","Warn: Project is vulnerable to: GHSA-7w75-32cg-r6g2","Warn: Project is vulnerable to: GHSA-83qj-6fr2-vhqg","Warn: Project is vulnerable to: GHSA-fccv-jmmp-qg76","Warn: Project is vulnerable to: GHSA-g8pj-r55q-5c2v","Warn: Project is vulnerable to: GHSA-h2fw-rfh5-95r3","Warn: Project is vulnerable to: GHSA-h3gc-qfqq-6h8f","Warn: Project is vulnerable to: GHSA-hfrx-6qgj-fp6c","Warn: Project is vulnerable to: GHSA-q3mw-pvr8-9ggc","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GHSA-r6j3-px5g-cq3x","Warn: Project is vulnerable to: GHSA-rq2w-37h9-vg94","Warn: Project is vulnerable to: GHSA-wc4r-xq3c-5cf3","Warn: Project is vulnerable to: GHSA-wm9w-rjj3-j356","Warn: Project is vulnerable to: GHSA-v682-8vv8-vpwr","Warn: Project is vulnerable to: GHSA-xf96-w227-r7c4","Warn: Project is vulnerable to: GHSA-4gc7-5j7h-4qph","Warn: Project is vulnerable to: GHSA-4wp7-92pw-q264","Warn: Project is vulnerable to: GHSA-564r-hj7v-mcr5","Warn: Project is vulnerable to: GHSA-wxqc-pxw9-g2p8","Warn: Project is vulnerable to: GHSA-2rmj-mq67-h97g","Warn: Project is vulnerable to: GHSA-2wrp-6fg6-hmc5","Warn: Project is vulnerable to: GHSA-ccgv-vj62-xf9h","Warn: Project is vulnerable to: GHSA-hgjh-9rj2-g67j","Warn: Project is vulnerable to: GHSA-cx7f-g6mp-7hqm","Warn: Project is vulnerable to: GHSA-g5vr-rgqm-vf78","Warn: Project is vulnerable to: GHSA-v94h-hvhg-mf9h","Warn: Project is vulnerable to: GHSA-mjmj-j48q-9wg2"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T02:54:23.625Z","repository_id":57732542,"created_at":"2025-08-17T02:54:23.625Z","updated_at":"2025-08-17T02:54:23.625Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34281700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["distributed-session","session","session-management"],"created_at":"2025-01-11T20:33:54.607Z","updated_at":"2026-06-13T10:31:48.199Z","avatar_url":"https://github.com/babyblue94520.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sync Session\n\n## Overview\n\nSyncSession is an architecture designed for distributed systems. Session data is stored in RDBS. It sends events to\nsynchronize session status in all services.\n\nRegularly update lastAccessTime to reduce the load of RDBS and improve concurrent processing capabilities\n\n## Requirement\n\n* Spring Boot 3+\n* Java 17+\n* Database (support MySQL and H2)\n\n## QuickStart\n\n1. **Config**\n\n    ```java\n    @EnableSyncSession\n    public class SessionConfig {\n\n    }\n    ```\n\n   **Distributed System**\n\n   If your infrastructure is a distributed system. You must implement SyncSessionEventService\n\n    ```java\n    /**\n    * Cases of using redis.\n    */\n    @Service\n    public class SyncSessionEventServiceImpl extends SyncSessionEventService implements InitializingBean {\n        @Autowired\n        private StringRedisTemplate stringRedisTemplate;\n\n        @Autowired\n        private RedisMessageListenerContainer listenerContainer;\n\n        @Autowired\n        private DefaultClientResources defaultClientResources;\n\n        private final String topic = \"session\";\n   \n        @Override\n        public void afterPropertiesSet() {\n            defaultClientResources.eventBus().get().subscribe((event) -\u003e {\n                if (event instanceof ConnectedEvent) {\n                    publishConnectedEvent();\n                }\n            });\n        }\n\n        @Override\n        public void send(String body) {\n            stringRedisTemplate.convertAndSend(body);\n        }\n\n        @Override\n        public void addListener(Consumer\u003cString\u003e listener) {\n            listenerContainer.addMessageListener((message, pattern) -\u003e {\n                listener.accept(new String(message.getBody()));\n            }, new PatternTopic(topic));\n        }\n    }\n    ```\n\n2. **Use**\n\n    * **Session operation**\n\n      RequestCacheHolder can be used anywhere.\n\n        ```java\n        public class CustomFilter implements Filter {\n        \n            @Override\n            public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {\n                RequestCache\u003cSyncSession\u003e requestCache = RequestCacheHolder.get();\n                // get session\n                SyncSession syncSession = requestCache.getSession();\n                // auto create session\n                SyncSession syncSession = requestCache.getSession(true);\n                // invalidate session\n                syncSession.invalidate();\n            }\n        }\n        ```\n\n    * **Filter**\n\n        ```java\n        public class CustomFilter implements Filter {\n        \n            @Override\n            public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {\n                RequestCache\u003cCustomSession\u003e requestCache = RequestCacheHolder.get(CustomSession.class);\n                // get session\n                SyncSession syncSession = requestCache.getSession();\n                syncSession.setCsrfToken(\"{token}\");\n            }\n        }\n        ```\n\n## Advanced\n\n### **Session properties**\n\n```yaml\nsync-session:\n  cookie-name: SSESSIONID\n  timeout: 30m\n```\n\n### **Session invalidate listener**\n\nUnder the distributed service architecture, the session will be invalidated by any service, so through **InvalidateBy**,\nit is recognized whether the current service is invalidated or the notification from another service.\n\n* InvalidateBy\n\n    * **SELF**: Indicates that the session is invalidated by the current service.\n\n    * **NOTICE**: Indicates that the session is invalidated by another service.\n\n```java\n\n@EnableSyncSession\npublic class SessionConfig implements InitializingBean {\n    @Autowired\n    private SyncSessionService\u003c?\u003e syncSessionServie;\n\n    @Override\n    public void afterPropertiesSet() throws Exception {\n        syncSessionServie.addInvalidateListeners((id, name, type) -\u003e {\n            log.info(\"{} {} {}\", id, name, type);\n        });\n    }\n}\n```\n\n### **Set custom attribute**\n\n1. **Create Custom Session**\n\n    ```java\n    public class UserSession extends SyncSession {\n        private String csrfToken;\n    \n        public String getCsrfToken() {\n            return csrfToken;\n        }\n    \n        public void setCsrfToken(String csrfToken) {\n            this.csrfToken = csrfToken;\n            // The mask data has changed\n            this.save();\n        }\n    }\n    ```\n\n2. **Extends SyncSessionServiceImpl**\n\n    ```java\n    public class CustomSessionService extends SyncSessionServiceImpl\u003cCustomSession\u003e {\n        public UserSessionService(\n            SyncSessionProperties properties\n            , DataSource dataSource\n            , @Nullable SyncSessionEventService sessionEventService\n        ) {\n            super(properties, dataSource, sessionEventService);\n        }\n    }\n    ```\n\n### **Invalidate by username**\n\nSometime need to invalidate all sessions by username.\n\n```java\npublic class UserSession {\n    @Autowired\n    private SyncSessionService syncSessionService;\n\n    public void kick(String username) {\n        syncSessionService.invalidateByUsername(username);\n    }\n\n    public void kickOther(String username) {\n        String[] excludeSessionIds = {\"....\"};\n        syncSessionService.invalidateByUsername(username, excludeSessionIds);\n    }\n}\n```\n\n### **Manage other system sessions**\n\nManage other system sessions by central management system.\n\n1. **Create SyncSessionOperatorService**\n\n   ```java\n   @Configuration\n   public class OtherSessionConfig {\n   \n       @Bean\n       @Autowired\n       public SyncSessionOperatorService\u003cSyncSession\u003e otherSyncSessionOperatorService(\n              DataSource dataSource // other session storage\n               , SyncSessionEventService sessionEventService\n       ) {\n           return new SyncSessionOperatorService\u003c\u003e(new SyncSessionProperties(), dataSource, sessionEventService);\n       }\n   }\n   ```\n\n2. **Use SyncSessionOperatorService**\n\n   ```java\n   public class OtherUserService{\n        @Autowired\n        private SyncSessionOperatorService\u003cSyncSession\u003e otherSyncSessionOperatorService;\n   \n        public void kick(String username){\n            otherSyncSessionOperatorService.invalidateByUsername(username);\n        }\n   }\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabyblue94520%2Fsync-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabyblue94520%2Fsync-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabyblue94520%2Fsync-session/lists"}