1.0.6+1
This commit is contained in:
parent
63daca458d
commit
3617f05b7b
4 changed files with 13 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
# angel_websocket
|
# 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)
|
[![build status](https://travis-ci.org/angel-dart/websocket.svg)](https://travis-ci.org/angel-dart/websocket)
|
||||||
|
|
||||||
WebSocket plugin for Angel.
|
WebSocket plugin for Angel.
|
||||||
|
|
|
@ -216,7 +216,11 @@ abstract class BaseWebSocketClient extends BaseAngelClient {
|
||||||
|
|
||||||
/// Attempts to authenticate a WebSocket, using a valid JWT.
|
/// Attempts to authenticate a WebSocket, using a valid JWT.
|
||||||
void authenticateViaJwt(String jwt) {
|
void authenticateViaJwt(String jwt) {
|
||||||
send(ACTION_AUTHENTICATE, new WebSocketAction(params: {'jwt': jwt}));
|
send(
|
||||||
|
ACTION_AUTHENTICATE,
|
||||||
|
new WebSocketAction(params: {
|
||||||
|
'query': {'jwt': jwt}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,10 +219,11 @@ class AngelWebSocket extends AngelPlugin {
|
||||||
Future handleAuth(WebSocketAction action, WebSocketContext socket) async {
|
Future handleAuth(WebSocketAction action, WebSocketContext socket) async {
|
||||||
if (allowAuth != false &&
|
if (allowAuth != false &&
|
||||||
action.eventName == ACTION_AUTHENTICATE &&
|
action.eventName == ACTION_AUTHENTICATE &&
|
||||||
action.params['jwt'] is String) {
|
action.params['query'] is Map &&
|
||||||
|
action.params['query']['jwt'] is String) {
|
||||||
try {
|
try {
|
||||||
var auth = socket.request.grab<AngelAuth>(AngelAuth);
|
var auth = socket.request.grab<AngelAuth>(AngelAuth);
|
||||||
var jwt = action.params['jwt'] as String;
|
var jwt = action.params['query']['jwt'] as String;
|
||||||
AuthToken token;
|
AuthToken token;
|
||||||
|
|
||||||
token = new AuthToken.validate(jwt, auth.hmac);
|
token = new AuthToken.validate(jwt, auth.hmac);
|
||||||
|
@ -243,6 +244,9 @@ class AngelWebSocket extends AngelPlugin {
|
||||||
else
|
else
|
||||||
socket.sendError(new AngelHttpException(e));
|
socket.sendError(new AngelHttpException(e));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
socket.sendError(new AngelHttpException.badRequest(
|
||||||
|
message: 'No JWT provided for authentication.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: angel_websocket
|
||||||
description: WebSocket plugin for Angel.
|
description: WebSocket plugin for Angel.
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=1.19.0"
|
sdk: ">=1.19.0"
|
||||||
version: 1.0.6
|
version: 1.0.6+1
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_websocket
|
homepage: https://github.com/angel-dart/angel_websocket
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Loading…
Reference in a new issue