3

We are building a mobile app using Flutter that connects to WebSocket (AWS). The user will SignUp / SignIn to the app using AWS Amplify Auth. After authentication is successful the app will establish a connection to WebSocket on AWS. In order to make our connection to WebSocket secure, we want to use AWS Signer v4 to sign the URL. But we couldn't find any support on AWS Signer v4 for Flutter. Kindly provide us help so that we can use Signer v4 using Flutter something like plugin etc.

Thank You

Nilesh
  • 31
  • 1

3 Answers3

2

I have almost exactly the same use case you have. I have written and released a simple library that can do what you want, creating a presigned URL to connect to AWS WebSocket API Gateway secured by IAM:

https://github.com/MohammedNoureldin/aws_url_signer

Basically you will get your signed URL just like this:

String getSignedWebSocketUrl(
    {String apiId,
    String region,
    String stage,
    String accessKey,
    String secretKey,
    String sessionToken})
Mohammed Noureldin
  • 14,913
  • 17
  • 70
  • 99
  • I made some amends to make it work for the AWS Transcribe API. Not sure if that service has a slightly different format or the code in Mohammed's has fallen out of date.... Check the diff for comparison. https://github.com/Air-Craft/aws_url_signer – Hari Honor Jun 15 '21 at 10:52
1

You can use package https://pub.dev/packages/sigv4
A Dart library for signing AWS requests with Signature Version 4.
code snippet

final client = Sigv4Client(
  keyId: 'your_access_key_id',
  accessKey: 'your_access_key',
  region: 'eu-west-1',.
  serviceName: 'execute-api',
);
chunhunghan
  • 51,087
  • 5
  • 102
  • 120
  • This lib for some reasons signs a few headers in addition to just "host" which is what aws wants for websockets. It's also no longer maintained :/ – Hari Honor Jun 14 '21 at 15:11
1

I have been looking for the same thing: an AWS Signer (v4) for sending API calls from my Flutter app to AWS services.

I found this package lately, tested it and think it does the job well https://pub.dev/packages/aws_signature_v4.

Emre Onay
  • 11
  • 3