# OpenSearch: \[security\_exception\] authentication/authorization failure

**URL:** <https://forum.opensearch.org/t/opensearch-security-exception-authentication-authorization-failure/24321>\
**Category:** Security\
**Tags:** security-issue\
**Created:** [May 9, 2025, 3:03pm UTC](https://forum.opensearch.org/t/opensearch-security-exception-authentication-authorization-failure/24321 "2025-05-09T15:03:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MA1](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MA1](https://forum.opensearch.org/u/MA1)\
**Post date:** [May 9, 2025, 3:03pm UTC](https://forum.opensearch.org/t/opensearch-security-exception-authentication-authorization-failure/24321/1 "2025-05-09T15:03:30Z")

</div>

I have spring boot app deployed to AWS EKS, and an OpenSearch server on AWS, I’m getting this error when the java code below gets executed:

OpenSearch server:

```auto
Managed opensearch cluster,
version: 2.11,
VPC

```

Error:

```auto
  [security_exception] authentication/authorization failure
        at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse(AwsSdk2Transport.java:54
1) ~[opensearch-java-2.22.0.jar!/:?]

```

Java code:

```auto
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
    
    OpenSearchClient client = new OpenSearchClient(
        new AwsSdk2Transport(
            httpClient,
            "search-...us-west-2.es.amazonaws.com", // OpenSearch endpoint, without https://
            "es",
            Region.US_WEST_2, // signing service region
            AwsSdk2TransportOptions.builder().build()
        )
    );
    
    String indexName = "test-index";
    
    BooleanResponse booleanResponse = openSearchClient
                        .indices()
                        .exists(ExistsRequest.of(builder -> builder.index(List.of(indexName))));

```

Pom.xml:

```auto
    <dependency>
        <groupId>org.opensearch.client</groupId>
        <artifactId>opensearch-java</artifactId>
        <version>2.22.0</version>
    </dependency>
    <dependency>
        <groupId>org.opensearch.client</groupId>
        <artifactId>opensearch-rest-client</artifactId>
        <version>2.19.1</version>
    </dependency>

```

Access policy:

```auto
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "es:*",
      "Resource": "arn:aws:es:us-west-2:987654321098:domain/my-domain/*"
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [May 14, 2025, 1:15pm UTC](https://forum.opensearch.org/t/opensearch-security-exception-authentication-authorization-failure/24321/2 "2025-05-14T13:15:55Z")

</div>

@MA1 Did you test authentication/authorization with awscurl?

```auto
 awscurl --service es --region us-west-2 --access_key <ACCESS_KEY> --secret_key <SECRET_ACCESS_KEY> <https://OpenSearch_Endpoint>

```

Does your IAM user has OpenSearch policy attached?

i.e.

```auto
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "es:*",
            "Resource": "*"
        }
    ]
}

```
