spring-bootazureapisecuritykey

Spring boot API key setup for azure web app


I have problem with API key for azure web app. I have Spring Boot application in which I set up SecurityConfiguration and APIKeyAuthenticationFilter Localy with Poatman everything works fine (I specify the header and KEY in the Postman environment). But after deployment I have Whitelabel Error Page 403 Access Denied.

Regarding security, in application.yaml I have

#Security
ecoopt:
  http:
   auth-apikey-header-name: MyAppAPIKey
   auth-header-apikey: ${env.ecoopt_apikey:DEFAULT_API_PASSWORD}

The values are used in SecurityConfiguration like this

@Value("${ecoopt.http.auth-header-apikey}")
private String principalRequestValue;

@Value("${ecoopt.http.auth-apikey-header-name}")
private String principalRequestHeader;

Again. localy using Postman everything is ok.

How to specify my environment variable which is the ecoopt_apikey in Azure Portal -> Configuration-> Appplication Settings... Should it look like - Name: ecoopt_http_auth-header-apikey and value: mySecretKey

enter image description here


Solution

  • Whitelabel Error Page 403 Access Denied

    How to specify my environment variable which is the ecoopt_apikey in Azure Portal

    As per my understanding, you are trying to add ecoopt_apikey and its value as Application Settings in App Service.

    enter image description here