Keycloak 21.1.1自定义端点异常求助,附示例项目
Keycloak 21.1.1 自定义端点问题排查请求
我在Keycloak 21.1.1版本中添加了一个自定义测试端点,项目内的问题描述、Keycloak日志文件及错误位置文件均存放于项目的custom_endpoint/options/1路径下。请帮忙排查问题,谢谢!
以下是我的Java端点类代码:
import jakarta.ws.rs.GET; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.ext.Provider; import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; import org.eclipse.microprofile.openapi.annotations.media.Content; import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; import org.jboss.logging.Logger; import org.keycloak.models.KeycloakSession; import org.keycloak.services.resource.RealmResourceProvider; //参考示例项目实现 @Provider @javax.ws.rs.Path("/") public class CustomEndpointResource implements RealmResourceProvider { private static final Logger logger = Logger.getLogger(CustomEndpointResource.class); private final KeycloakSession session; public CustomEndpointResource(KeycloakSession session) { this.session = session; } @javax.ws.rs.Path("custom") @GET @Produces(MediaType.APPLICATION_JSON) @Operation( summary = "Public hello endpoint", description = "This endpoint returns hello and the name of the requested realm." ) @APIResponse( responseCode = "200", description = "", content = {@Content( schema = @Schema( implementation = String.class, type = SchemaType.STRING ) )} ) public String customTest() { logger.info("called custom endpoint!"); return "Test!"; } @Override public Object getResource() { logger.info("CUSTOM RealmResourceProvider.getResource"); return this; } @Override public void close() { logger.info("CUSTOM RealmResourceProvider.close"); } }
内容的提问来源于stack exchange,提问作者JDev
相关产品推荐
相关产品推荐

