diff --git a/README.md b/README.md index fe927ca..574bb5a 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,14 @@ as binary data. The resulting `StompFrame` will have a `binaryBody`. The `body` frame will be empty in this case. The same is true if the `content-type` header is missing. +## Token Authentication (browser-based clients) + +Browser clients can only use standard authentication headers (that is, basic HTTP authentication) or cookies and [cannot provide custom headers](https://github.com/whatwg/websockets/issues/16#issuecomment-332065542) (such as "Authorization" to use a Bearer token). Thus `webSocketConnectHeaders` will do nothing in a browser environment. +Alternatives are: +- Use the STOMP client to pass authentication headers at connect time. (recommended) + - Use `stompConnectHeaders` to pass your headers in the `CONNECT` frame. Parse those headers on the server (i.e. by using a `ChannelInterceptor` in Spring) +- Pass your authentication token/credentials as query parameter. + ## Development #### Running unit tests diff --git a/lib/stomp_parser.dart b/lib/stomp_parser.dart index f68efec..68231d0 100644 --- a/lib/stomp_parser.dart +++ b/lib/stomp_parser.dart @@ -50,8 +50,7 @@ class StompParser implements Parser { } else if (data is List) { byteList = Uint8List.fromList(data); } else { - throw UnsupportedError( - 'Input data type unsupported ${data.runtimeType}'); + throw UnsupportedError('Input data type unsupported ${data.runtimeType}'); } for (var i = 0; i < byteList.length; i++) { diff --git a/pubspec.yaml b/pubspec.yaml index a6eaf2f..320c048 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,12 +3,12 @@ homepage: https://github.com/blackhorse-one/stomp_dart version: 0.4.4 description: Dart STOMP client for easy messaging interoperability. Build with flutter in mind, but should work for every dart application. environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: web_socket_channel: ^2.0.0 dev_dependencies: - test: ^1.16.5 - lints: ^2.0.0 - stream_channel: ^2.1.0 + test: ^1.23.1 + lints: ^2.0.1 + stream_channel: ^2.1.1 diff --git a/test/stomp_parser_test.dart b/test/stomp_parser_test.dart index 00e35af..a1d96e3 100644 --- a/test/stomp_parser_test.dart +++ b/test/stomp_parser_test.dart @@ -307,7 +307,9 @@ void main() { count: 2, ); - StompParser(onFrame)..parseData(msg)..parseData(msg2); + StompParser(onFrame) + ..parseData(msg) + ..parseData(msg2); }); test('can parse multiple messages at once', () { @@ -455,7 +457,9 @@ void main() { count: 2, ); - StompParser(callback)..parseData(msg)..parseData(msg2); + StompParser(callback) + ..parseData(msg) + ..parseData(msg2); }); group('when content-type is missing', () { diff --git a/test/stomp_test.dart b/test/stomp_test.dart index 6c6c380..029e307 100644 --- a/test/stomp_test.dart +++ b/test/stomp_test.dart @@ -11,7 +11,6 @@ import 'package:test/test.dart'; void main() { group('StompClient', () { late StompConfig config; - StompHandler? handler; late StreamChannel streamChannel; setUpAll(() async { @@ -78,10 +77,6 @@ void main() { ); }); - tearDown(() async { - handler?.dispose(); - }); - tearDownAll(() async { await streamChannel.sink.close(); });