This commit is contained in:
thosakwe 2017-04-23 14:53:12 -04:00
parent 63daca458d
commit 3617f05b7b
4 changed files with 13 additions and 5 deletions

View file

@ -1,5 +1,5 @@
# angel_websocket
[![1.0.6](https://img.shields.io/badge/pub-1.0.6-brightgreen.svg)](https://pub.dartlang.org/packages/angel_websocket)
[![1.0.6+1](https://img.shields.io/badge/pub-1.0.6+1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_websocket)
[![build status](https://travis-ci.org/angel-dart/websocket.svg)](https://travis-ci.org/angel-dart/websocket)
WebSocket plugin for Angel.

View file

@ -216,7 +216,11 @@ abstract class BaseWebSocketClient extends BaseAngelClient {
/// Attempts to authenticate a WebSocket, using a valid JWT.
void authenticateViaJwt(String jwt) {
send(ACTION_AUTHENTICATE, new WebSocketAction(params: {'jwt': jwt}));
send(
ACTION_AUTHENTICATE,
new WebSocketAction(params: {
'query': {'jwt': jwt}
}));
}
}

View file

@ -219,10 +219,11 @@ class AngelWebSocket extends AngelPlugin {
Future handleAuth(WebSocketAction action, WebSocketContext socket) async {
if (allowAuth != false &&
action.eventName == ACTION_AUTHENTICATE &&
action.params['jwt'] is String) {
action.params['query'] is Map &&
action.params['query']['jwt'] is String) {
try {
var auth = socket.request.grab<AngelAuth>(AngelAuth);
var jwt = action.params['jwt'] as String;
var jwt = action.params['query']['jwt'] as String;
AuthToken token;
token = new AuthToken.validate(jwt, auth.hmac);
@ -243,6 +244,9 @@ class AngelWebSocket extends AngelPlugin {
else
socket.sendError(new AngelHttpException(e));
}
} else {
socket.sendError(new AngelHttpException.badRequest(
message: 'No JWT provided for authentication.'));
}
}

View file

@ -2,7 +2,7 @@ name: angel_websocket
description: WebSocket plugin for Angel.
environment:
sdk: ">=1.19.0"
version: 1.0.6
version: 1.0.6+1
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_websocket
dependencies: