简体   繁体   English

Java EE 应用程序中的 OAuth2 访问令牌

[英]OAuth2 Access Token in Java EE Applications


I'm trying to find a way to use OAuth2 Access Token authentication in a Java Enterprise application.我正在尝试找到一种在 Java 企业应用程序中使用 OAuth2 访问令牌身份验证的方法。 So far, the only examples I've found are relevant to Spring Boot.到目前为止,我发现的唯一示例与 Spring Boot 有关。 For example, Spring Boot applications are able to define properties to access a Keycloak server and specify realm and client:例如,Spring 引导应用程序能够定义属性以访问 Keycloak 服务器并指定 realm 和客户端:

keycloak.realm=spring-boot-quickstart
keycloak.auth-server-url=http://localhost:8180/auth
keycloak.ssl-required=external
keycloak.resource=app-authz-rest-employee
keycloak.bearer-only=true
keycloak.credentials.secret=secret
keycloak.securityConstraints[0].authRoles[0]=user
keycloak.securityConstraints[0].securityCollections[0].name=protected
keycloak.securityConstraints[0].securityCollections[0].patterns[0]=/*
keycloak.policy-enforcer-config.enforcement-mode=ENFORCING
keycloak.policy-enforcer-config.claimInformationPointConfig.claims[http.uri]={request.relativePath}

Is there an equivalent configuration you can use for a Java Enterprise Application?是否有可用于 Java 企业应用程序的等效配置? Within the web.xml it seems you can only specify KEYCLOAK as auth-method:在 web.xml 中,您似乎只能将 KEYCLOAK 指定为身份验证方法:

 <auth-method>KEYCLOAK</auth-method>

but that simply redirects to keycloak login challenge.但这只是重定向到keycloak登录挑战。 I'd like rather to use Tokens.我宁愿使用代币。 Maybe System Properties or other ways?也许系统属性或其他方式? Thanks谢谢

There are official examples of java ee sample applications secured by Keycloak有由 Keycloak 保护的 java ee 示例应用程序的官方示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM