【Static Web Apps】GetRoles function not working
Hi,
I'm developing static web application with react and Java(Spring Boot).
I want to manage users with Entra ID and user roles with DB.
So I deployed SWA with custom authentication, but GetRoles Function is not working.
Can anyone detect the cause of this problem?
GetRoles Function (Java)
package com.ms.samples.demo.mscs_az_functions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.stereotype.Component;
import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.HttpResponseMessage;
import com.microsoft.azure.functions.HttpStatus;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;
@Component
public class GetRoles {
@FunctionName("GetRoles")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");
// レスポンスの作成
Map<String, Object> responseBody = new HashMap<>();
List<String> roles = new ArrayList<String>();
roles.add("CLIENT");
roles.add("ADMINISTRATOR");
roles.add("GETROLES");
responseBody.put("roles", roles);
return request.createResponseBuilder(HttpStatus.OK).body(responseBody).build();
}
}
/.auth/me
I viewed this manual, but problem is not solved.
https://learn.microsoft.com/en-us/azure/static-web-apps/authentication-custom?tabs=aad%2Cinvitations
Best Regard.