{"id":23542621,"url":"https://github.com/kguzek/stomp-auth-client","last_synced_at":"2025-10-28T16:52:26.836Z","repository":{"id":263701824,"uuid":"891217772","full_name":"kguzek/stomp-auth-client","owner":"kguzek","description":"A Java STOMP WebSocket client with support for HTTP authentication.","archived":false,"fork":false,"pushed_at":"2025-04-24T15:23:57.000Z","size":44,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T06:38:57.096Z","etag":null,"topics":["authentication","http","java","messaging","stomp","stompwebsocket","websocket-client","websockets"],"latest_commit_sha":null,"homepage":"https://central.sonatype.com/artifact/uk.guzek/stomp-auth-client","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kguzek.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,"zenodo":null}},"created_at":"2024-11-19T23:57:42.000Z","updated_at":"2025-04-24T15:24:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"936c9fb4-04b3-4f70-b860-3c6fb76717d2","html_url":"https://github.com/kguzek/stomp-auth-client","commit_stats":null,"previous_names":["kguzek/stomp-auth-client"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kguzek/stomp-auth-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kguzek%2Fstomp-auth-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kguzek%2Fstomp-auth-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kguzek%2Fstomp-auth-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kguzek%2Fstomp-auth-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kguzek","download_url":"https://codeload.github.com/kguzek/stomp-auth-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kguzek%2Fstomp-auth-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264903212,"owners_count":23681127,"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":["authentication","http","java","messaging","stomp","stompwebsocket","websocket-client","websockets"],"created_at":"2024-12-26T06:13:50.952Z","updated_at":"2025-10-28T16:52:21.782Z","avatar_url":"https://github.com/kguzek.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STOMP Auth Client\n\n## Description\n\nSAC is essentially a STOMP wrapper to [Java-WebSocket](https://github.com/TooTallNate/Java-WebSocket). I created it since I use HTTP-based authentication on my Spring Boot server, and STOMP messaging is very easy to integrate into that existing workflow.\nHowever, most STOMP clients use a custom authentication method done internally, and require the HTTP Upgrade route to be unprotected on the server. This is why I decided to create my own library which allows the authentication to be performed on the request level.\n\nFor more details on the issue addressed by this solution, refer to this discussion on StackOverflow:\n\n- https://stackoverflow.com/questions/45405332/websocket-authentication-and-authorization-in-spring\n\nThis approach isn't needed when integrating websockets into a Spring-based client, but it is the only currently available option when creating non-Spring Java applications.\n\n## Getting Started\n\n### Installation (Maven)\n\nThis project is available on the central [Maven Sonatype repository](https://central.sonatype.com/artifact/uk.guzek/stomp-auth-client).\nTo use it in your code, paste the following into your `pom.xml`.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003euk.guzek\u003c/groupId\u003e\n    \u003cartifactId\u003estomp-auth-client\u003c/artifactId\u003e\n    \u003cversion\u003e1.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\nAt the time of writing, the latest version is `1.1.1`. You can always check this here:\n\nhttps://central.sonatype.com/artifact/uk.guzek/stomp-auth-client/versions\n\n### Logging\n\nPlease refer to the Java-WebSocket README regarding logging, as the same applies here.\n\nhttps://github.com/TooTallNate/Java-WebSocket#logging\n\n## Usage\n\nThe API is very similar to Java-Websocket's: you need to create your own implementation of the `StompClient` abstract class, then operate on an instance of that class.\n\nTo create such a class, simply extend the `StompClient` from this package.\n```java\nimport uk.guzek.sac.StompClient;\n\npublic class ExampleClient extends StompClient {\n  // ...\n}\n```\n\nThen, assuming such a class has implemented all the necessary abstract methods: \n```java\nExampleClient client = new ExampleClient(URI.create(serverUri), AuthType.jwt(token), host);\n// remember to call `.connect()` after initialising the client\nclient.connect();\nclient.subscribe(\"/topic/greetings\",\n        (Map\u003cString, String\u003e headers, String body) -\u003e logger.debug(\"Greeted: '\" + body + \"'\")\n);\nclient.sendText(\"test message\", \"/app/test\");\n```\n\nBelow is an example of code that could be used to create a web server in Spring which would correctly handle the above client invocation.\n\n```java\n// configuration class\n@Configuration\n@RequiredArgsConstructor\n@EnableWebSocketMessageBroker\npublic class ApplicationConfig implements WebSocketMessageBrokerConfigurer {\n    @Override\n    public void registerStompEndpoints(@NonNull StompEndpointRegistry registry) {\n        registry.addEndpoint(\"/api/v1/staff/stomp\").setAllowedOrigins(\"*\");\n    }\n\n    @Override\n    public void configureMessageBroker(@NonNull MessageBrokerRegistry config) {\n        config.enableSimpleBroker(\"/topic\");\n        config.setApplicationDestinationPrefixes(\"/app\");\n    }\n}\n\n// controller class\n@Controller\npublic class WebsocketController {\n    @MessageMapping(\"/test\")\n    @SendTo(\"/topic/greetings\")\n    public String greeting(String message) {\n        System.out.println(\"Received message: '\" + message + \"'\");\n        return \"Hello, \" + message + \"!\";\n    }\n}\n```\n\nFor a more complete client implementation example, refer to [src/main/java/uk/guzek/sac/examples/ExampleClient.java](https://github.com/kguzek/stomp-auth-client/blob/main/src/main/java/uk/guzek/sac/examples/ExampleClient.java).\n\n###### Thank you for reading!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkguzek%2Fstomp-auth-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkguzek%2Fstomp-auth-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkguzek%2Fstomp-auth-client/lists"}