# Securing front doors by signing standard requests with the AWS SDK v2

DevFeed: [Securing front doors by signing standard requests with the AWS SDK v2](<https://devfeed.tech/articles/securing-front-doors-by-signing-standard-requests-with-the-aws-sdk-v2-23974.md>)

Original publisher: [Read original article](<https://medium.com/making-meetup/securing-front-doors-by-signing-standard-requests-with-the-aws-v2-sdk-03a0b9028ce9?source=rss----6981e268ba45---4>)

Author: Doug Tangren

Published: 2024-01-19T19:52:03Z

Content type: tutorial

Language: en

Sources: [Making Meetup - Medium](<https://devfeed.tech/sources/making-meetup-medium.md>)

Topics: [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [AWS IAM](<https://devfeed.tech/topics/aws-iam.md>), [Java](<https://devfeed.tech/topics/java.md>), [SDKs](<https://devfeed.tech/topics/sdks.md>), [Java HttpClient](<https://devfeed.tech/topics/java-httpclient.md>), [Security](<https://devfeed.tech/topics/security.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [AWS Lambda](<https://devfeed.tech/topics/aws-lambda.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [api-management](<https://devfeed.tech/tags/api-management.md>), [aws](<https://devfeed.tech/tags/aws.md>), [aws-lambda](<https://devfeed.tech/tags/aws-lambda.md>), [http](<https://devfeed.tech/tags/http.md>), [iam](<https://devfeed.tech/tags/iam.md>), [java](<https://devfeed.tech/tags/java.md>), [sdk](<https://devfeed.tech/tags/sdk.md>), [security](<https://devfeed.tech/tags/security.md>)

## AI overview

This tutorial explains how to sign standard Java HttpClient requests with AWS Signature Version 4 using the AWS SDK v2. It describes authenticating requests with IAM credentials and includes an AWS SAM example for protecting Lambda Function URLs with AWS_IAM authentication.

## Source excerpt

Photo by Masaaki Komori on Unsplash Security is not an optional feature when designing networked services, especially those accessible over the internet. It's a given. For this reason secure services must be authenticated. There are an innumerable ways to solve this problem in the technology space. Fortunately for AWS customers, this is a wheel that needs no reinventing. There is a solution for this with AWS and it's called sig v4 signing: a specification for authenticating a HTTP requests with IAM credentials in a way that AWS services can then validate them before providing access to your services capabilities. Sig v4 is such a common a feature for securing your AWS infrastructure that in many cases it's almost as easy as a one line change to your infrastructure definition to add it. Here's an example of adding sig v4 auth protection to your AWS Lambda Function URLs in a sam template for illustration. AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Resources: CoolApi: Type: AWS::Serverless::Function Properties: # 👇 give your function a Http API URL FunctionUrlConfig: # 👇 yes, it's that easy AuthType: AWS_IAM # ... the rest As AWS customers, Meetup uses sig v4 auth to secure a number of our own services. This implies we need clients which are able to sign requests to make any use of them. In this post I'd like to share our recipe to doing so by using what you likely already have in your kitchen cabinets: the AWS SDK that's likely already on your class path as well as the Java standard library HttpClient which requires no additional external dependencies. Below is a full example of a utility, sans javadocs and wildcarded imports for brevity which fits neatly into a single file which allows you to securely sign std lib HTTP requests used with the std lib HttpClient using AWS's Aws4Signer which uses it's own representation of HTTP requests. package com.meetup.sigv4.jdk; import static java.net.http.HttpRequest.BodyPublishers; import static