{"id":48280246,"url":"https://github.com/vzhn/netty-http-authenticator","last_synced_at":"2026-04-04T22:44:52.965Z","repository":{"id":35870442,"uuid":"184405316","full_name":"vzhn/netty-http-authenticator","owner":"vzhn","description":"Basic and digest HTTP authentication for Netty","archived":false,"fork":false,"pushed_at":"2023-04-18T22:20:56.000Z","size":207,"stargazers_count":12,"open_issues_count":3,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-20T07:41:20.881Z","etag":null,"topics":["digest-authentication","http","netty","rtsp"],"latest_commit_sha":null,"homepage":"","language":"Java","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/vzhn.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-01T11:14:43.000Z","updated_at":"2023-04-19T09:56:19.000Z","dependencies_parsed_at":"2023-01-16T08:15:24.142Z","dependency_job_id":null,"html_url":"https://github.com/vzhn/netty-http-authenticator","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/vzhn/netty-http-authenticator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhn%2Fnetty-http-authenticator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhn%2Fnetty-http-authenticator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhn%2Fnetty-http-authenticator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhn%2Fnetty-http-authenticator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vzhn","download_url":"https://codeload.github.com/vzhn/netty-http-authenticator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzhn%2Fnetty-http-authenticator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31418270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["digest-authentication","http","netty","rtsp"],"created_at":"2026-04-04T22:44:52.828Z","updated_at":"2026-04-04T22:44:52.944Z","avatar_url":"https://github.com/vzhn.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Travis (.org)](https://img.shields.io/travis/vzhn/netty-http-authenticator?style=plastic)\n![Maven Central](https://img.shields.io/maven-central/v/io.github.vzhn/netty-http-authenticator?style=plastic)\n\n### BasicNetyHttpAuthenticator\n`BasicNettyHttpAuthenticator` just appends the auth header to an every request.\n```java\nBootstrap b = new Bootstrap();\nb.group(group)\n .channel(NioSocketChannel.class)\n .handler(new ChannelInitializer\u003cSocketChannel\u003e() {\n     @Override\n     protected void initChannel(SocketChannel ch) {\n         ChannelPipeline p = ch.pipeline();\n         p.addLast(new HttpClientCodec());\n         p.addLast(new HttpObjectAggregator(1048576));\n         p.addLast(new BasicNettyHttpAuthenticator(\"scott\", \"tiger\"));\n         p.addLast(new HttpClientHandler());\n     }\n });\n```\n\n### DigestNettyHttpAuthenticator\n```java\nDigestAuthenticator digestAuthenticator = new DigestAuthenticator(\"scott\", \"tiger\");\n\nBootstrap b = new Bootstrap();\nb.group(group)\n .channel(NioSocketChannel.class)\n .handler(new ChannelInitializer\u003cSocketChannel\u003e() {\n     @Override\n     protected void initChannel(SocketChannel ch) {\n         ChannelPipeline p = ch.pipeline();\n         p.addLast(new HttpClientCodec());\n         p.addLast(new DigestNettyHttpAuthenticator(digestAuthenticator));\n         p.addLast(new HttpClientHandler());\n     }\n });\n\n...\n  ch.writeAndFlush(firstSequest); // the first request got 401 error\n  ch.writeAndFlush(secondRequest); // the second will succeeded if credentinals are not wrong\n```\n\n### TransparentDigestNettyHttpAuthenticator\nThis is the tricky one. It works only with aggregated HTTP messages: `FullHttpRequest` and `FullHttpResponse` and keep-alive connection. \nThe solution that fits for `RTSP`.\n\n`TransparentDigestNettyHttpAuthenticator` must be initialized with `username` and `password` and placed in a channel pipeline between `HttpObjectAggregator` \nand handler that processes server responses, like this:\n\n```java\nDigestAuthenticator digestAuthenticator = new DigestAuthenticator(\"scott\", \"tiger\");\n\nBootstrap b = new Bootstrap();\nb.group(group)\n .channel(NioSocketChannel.class)\n .handler(new ChannelInitializer\u003cSocketChannel\u003e() {\n     @Override\n     protected void initChannel(SocketChannel ch) {\n         ChannelPipeline p = ch.pipeline();\n         p.addLast(new HttpClientCodec());\n         p.addLast(new HttpObjectAggregator(1048576)); // NB! works only with aggregated request/response\n         p.addLast(new TransparentDigestNettyHttpAuthenticator(authenticator));\n         p.addLast(new HttpClientHandler());\n     }\n });\n..\n  ch.writeAndFlush(request); // the first attempt will succeeded if credentinals are not wrong\n```\n\n##### How it works\n`TransparentDigestNettyHttpAuthenticator` intercepts the client request, and remembers it\n* If a server returns the `401 Unathorized` error,  authenticator resends the request with proper authorization header\n* If a server returns `200 OK`, authenticator attaches the authorization header to all subsequent requests\n* If a server returns the `401 Unathorized` error again, and `stale=false`, authenticator pass that *error* to client (bad credentials)\n* If a server returns the `401 Unathorized error` and `stale=true`, authenticator generates a new client nonce and resend the request with new authorization header\n\nTypical client-server exchange may look like this:\n\n![Digest authenticator](digest-auth-sequence.png)\n\n\n## Downloading from the Maven central repository\nAdd the following dependency section to your pom.xml:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.vzhn\u003c/groupId\u003e\n    \u003cartifactId\u003enetty-http-authenticator\u003c/artifactId\u003e\n    \u003cversion\u003e1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## How to contribute\nMake your changes, and submit a pull request. Contributions are welcome!\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzhn%2Fnetty-http-authenticator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvzhn%2Fnetty-http-authenticator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzhn%2Fnetty-http-authenticator/lists"}