Context
I am working on a simple React app with a GraphQL backend, all hosted on AWS. I have custom authentication setup for GraphQL, using AWS Lambda, where each call to GraphQL contains a query or mutation, relevant variables, and the logged-in users' JWT token. Inside the lambda function, I verify the token; if the token is valid, I have logic to determine if the user can access the data they're requesting; if not, I deny all access. Currently, users' JWT token are exposed in the GraphQL call.
The code that sends the token is below, where lambdaAuthToken
is the JWT token.
import { API } from "aws-amplify";
import { GRAPHQL_AUTH_MODE } from "@aws-amplify/api";
const graphQLAuthMode = GRAPHQL_AUTH_MODE.AWS_LAMBDA;
export default async function fetchData(
queryTemplate,
queryVars,
lambdaAuthToken
) {
let response = [];
try {
response = await API.graphql({
query: queryTemplate,
variables: queryVars,
authMode: graphQLAuthMode,
authToken: lambdaAuthToken,
});
console.log(response);
} catch (err) {
console.log("Error fetching data.");
console.log(err);
}
return response;
}
Question(s)
Are there any security vulnerabilities with sending an unencrypted JWT token over the network? And if so, what might be an appropriate AWS-based encryption scheme to protect the token in transmission? (I'm working in React JS on the front-end, but my custom authentication lambda is in Python.)
Similar questions
I did see the following questions, but did not take any of them to address my questions here.