{"action":"created","issue":{"url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/23","labels_url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/23/comments","events_url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/23/events","html_url":"https://github.com/sunng87/ring-jetty9-adapter/issues/23","id":95787982,"number":23,"title":"准备加入鉴权功能","user":{"login":"paomian","id":2999156,"avatar_url":"https://avatars.githubusercontent.com/u/2999156?v=3","gravatar_id":"","url":"https://api.github.com/users/paomian","html_url":"https://github.com/paomian","followers_url":"https://api.github.com/users/paomian/followers","following_url":"https://api.github.com/users/paomian/following{/other_user}","gists_url":"https://api.github.com/users/paomian/gists{/gist_id}","starred_url":"https://api.github.com/users/paomian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paomian/subscriptions","organizations_url":"https://api.github.com/users/paomian/orgs","repos_url":"https://api.github.com/users/paomian/repos","events_url":"https://api.github.com/users/paomian/events{/privacy}","received_events_url":"https://api.github.com/users/paomian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-18T04:39:09Z","updated_at":"2015-07-18T05:12:23Z","closed_at":null,"body":"在 `createWebSocket` 可以加入鉴权功能，可以对 `cookie` 或者 `Sec-WebSocket-Protocol` 请求头进行鉴权，提供一个可以根据不同鉴权返回不同 `handler` 的功能"},"comment":{"url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/comments/122484491","html_url":"https://github.com/sunng87/ring-jetty9-adapter/issues/23#issuecomment-122484491","issue_url":"https://api.github.com/repos/sunng87/ring-jetty9-adapter/issues/23","id":122484491,"user":{"login":"paomian","id":2999156,"avatar_url":"https://avatars.githubusercontent.com/u/2999156?v=3","gravatar_id":"","url":"https://api.github.com/users/paomian","html_url":"https://github.com/paomian","followers_url":"https://api.github.com/users/paomian/followers","following_url":"https://api.github.com/users/paomian/following{/other_user}","gists_url":"https://api.github.com/users/paomian/gists{/gist_id}","starred_url":"https://api.github.com/users/paomian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paomian/subscriptions","organizations_url":"https://api.github.com/users/paomian/orgs","repos_url":"https://api.github.com/users/paomian/repos","events_url":"https://api.github.com/users/paomian/events{/privacy}","received_events_url":"https://api.github.com/users/paomian/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T05:12:22Z","updated_at":"2015-07-18T05:12:22Z","body":"鉴权能做到 app 里，但是必须要 adapter 里提供一个方法才行，因为 sokcet 的握手连接是在 WebSocketCreator 的 createWebSocket 这一步的，这一步直接就返回了一个 WebSocketHandler ，就是只要发起了 WebSocket 请求就是默认会连接的，而你在 on-conn 里做鉴权已经晚了，因为连接已经完成，可以在握手的时候就进行鉴权进行不必要的资源浪费\r\n\r\n[一个基本的鉴权的例子，还可以从 request 里拿更多的东西进行鉴权](https://eclipse.googlesource.com/jetty/org.eclipse.jetty.project/+/c114e925ef9a116aeb187342b785ae1fdd80051a/jetty-websocket/websocket-servlet/src/test/java/examples/MyAdvancedEchoCreator.java)\r\n[我们默认就返回了 handler](https://github.com/sunng87/ring-jetty9-adapter/blob/master/src/ring/adapter/jetty9.clj#L133)"}}