我在一个使用 Keycloak Spring Adapter 的项目中更新到了 Spring Boot 3。不幸的是,它没有启动,因为它 KeycloakWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter首先在 Spring Security 中被弃用,然后被删除。目前是否有另一种方法可以使用 Keycloak 实现安全性?或者换句话说:如何将 Spring Boot 3 与 Keycloak 适配器结合使用?
我在互联网上搜索,但找不到任何其他版本的适配器。
我正在尝试按照https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-migrate-accounts-regions/ 中的说明导出和导入 AWS Gateway API 。
导出工作:
aws apigateway get-export --parameters extensions='apigateway' --rest-api-id MY_REST_API_ID --stage-name Prod --export-type swagger my-api-apigateway.json
Run Code Online (Sandbox Code Playgroud)
我的 API 的相同文件是使用--parameters extensions='apigateway'
和生成的--parameters extensions='integrations'。
但是当我尝试从导出的文件中进行导入时:
aws apigateway import-rest-api --fail-on-warnings --body file://%cd%/my-api-gateway.json
Run Code Online (Sandbox Code Playgroud)
,我总是收到“无效的 base64:”错误。像这样:
Invalid base64: "{
"swagger" : "2.0",
"info" : {
"version" : "1.0",
"title" : "my-stack-name"
},
"host" : "MY_REST_API_ID.execute-api.eu-central-1.amazonaws.com",
"basePath" : "/Prod",
...
Run Code Online (Sandbox Code Playgroud)
谷歌上没有文档和示例说 body 应该是 Base64。
当我通过 UI(操作 -> 导入 API)导入它时,相同的 JSON 似乎有效。
我也尝试使用--cli-input-json:
my-api-apigateway-cli-json.json文件(根据aws apigateway …
我正在尝试使用 Keycloak 的 openId-connect 端点获取有关用户角色的信息。我正在使用/auth/realms/moje/protocol/openid-connect/userinfo端点来获取有关经过身份验证的用户的信息。我能够获取有关姓名、用户名、电子邮件等的信息,但我无法强制 Keycloak 向我提供有关用户角色的信息。
我已阅读 OpenID 文档,但没有找到任何有关如何获取角色的信息...我认为必须有一种方法可以找出用户角色...也许还有另一个端点...我可以'找不到任何信息...
最后我的问题是:有没有办法使用 OpenID Connect 端点获取有关用户角色的信息?
我正在尝试通过仅创建一个实例并将其通过流上的方法通过它们的实例来重用Observerfor Single和Observablestream :DisposableSingleObserver/DisposableObserversubscribeWith()
public class SomeClass {
private DisposableSingleObserver<Object> observer;
public SomeClass() {
observer = new DisposableSingleObserver<Object>() {
@Override
public void onSuccess(Object object) {
...
}
@Override
public void onError(Throwable throwable) {
...
}
};
}
public void doSomeStuff() {
singleStream.subscribeOn(...)
.observeOn(...)
.subscribeWith(observer);
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码导致ProtocolViolationException当我尝试通过消息多次订阅单个观察者实例时:
io.reactivex.exceptions.ProtocolViolationException:不允许多次使用com.package.name.SomeClass $ 1进行订阅。请创建com.package.name.SomeClass $ 1的新实例,然后将其订阅到目标源。
因此,我对代码进行了如下修改:
public class SomeClass {
...
public void doSomeStuff() {
if (observer != null) {
observer.dispose();
}
singleStream.subscribeOn(...)
.observerOn(...)
.subscribeWith(observer); …Run Code Online (Sandbox Code Playgroud) 我在捆绑有关如何解决此错误的任何建议时遇到了此类错误我已经通过删除额外的依赖项进行了尝试,但仍然不起作用
此外,如果在不知情的情况下错误地删除了任何模块,我还删除了节点模块并重新安装了它们。但还是不行。
可能有任何问题,但我无法解决它,自过去两天以来我一直面临并试图解决这个问题
我制作了一个示例默认捆绑包并且它有效,但这个应用程序没有捆绑我正在使用 Expo-react-native
Downloading https://services.gradle.org/distributions/gradle-7.3.3-all.zip
10%.
20%.
30%.
40
%
50
%.
60%.
70%.
80%.
90%
100%
Welcome to Gradle 7.3.3!
Here are the highlights of this release:
- Easily declare new test suites in Java projects
- Support for Java 17
- Support for Scala 3
For more details see https://docs.gradle.org/7.3.3/release-notes.html
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.3.3/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个表单,该表单将根据复选框刻度线启用和禁用。
<div class="row">
<div class="col-md-12">
<p>Is this client user</p>
<input
type="checkbox"
name="is_user"
id="is_user"
onclick="enableCreateUser()"
/>
</div>
</div>
<div class="row" id="user_register">
<div class="form-group row">
<div class="col-md-6">
<label class="" for="username">Username:</label>
</div>
<div class="col-md-6">
<input class="form-control" type="text" name="username"/>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<label class="" for="password">Password:</label>
</div>
<div class="col-md-6">
<input class="form-control" type="password" name="password"/>
</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我正在尝试制作这个 javascript 或 jquery 函数,它允许我使用id="user_register".
这是我尝试过的代码。
function enableCreateUser() {
if (document.getElementById("is_user").checked) {
document.getElementById("user_register").disabled = true;
}
if (!document.getElementById("is_user").checked) {
document.getElementById("user_register").disabled = false;
} …Run Code Online (Sandbox Code Playgroud) 我需要帮助jackson-dataformat-xml。我需要将List<String>using序列化XmlMapper到 xml 中,并对引号"\xe2\x86\x92进行编码"。
但是在序列化XmlMapper对所有其他特殊符号(<、等)进行编码后,但完全忽略引号(和)...如果我在序列化之前手动>编码字符串,内容会变得混乱,因为里面有并且它的序列化不是当然。&\'""\'&\'&quot;
也许有人知道如何让它发挥作用?\n另外,有没有一种解决方法可以List<String>使用@JacksonRawValue或类似的方法在字段上禁用自动特殊符号编码?此注释在简单(非数组)字段上效果很好,但在List<String>.
谢谢。
\n我正在尝试学习 Java Spring 并且完全像这里一样:https : //spring.io/guides/gs/securing-web/
但是我的 IDE 在导入配置时说“无法解析‘安全’符号”。我正在使用相同版本的 spring 并且具有相同的代码。我不知道出了什么问题。
package com.github.SpringSite.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user =
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
}
Run Code Online (Sandbox Code Playgroud)
我的 pom.xml …
我的Kotlin类TimeUtils有一个密封的类,声明为:
sealed class TimeUnit {
object Second : TimeUnit()
object Minute : TimeUnit()
fun setTimeOut(timeout : TimeUnit) {
// TODO something
}
Run Code Online (Sandbox Code Playgroud)
我的Java类正在调用如下setTimeOut方法:
TimeUtils obj = new TimeUtils();
if (some condition) {
obj.setTimeOut(TimeUtils.TimeUnit.Minute); // ERROR
} else if (some other condition) {
obj.setTimeOut(TimeUtils.TimeUnit.Second); // ERROR
}
Run Code Online (Sandbox Code Playgroud)
我在上面两行指出错误expression required。谁能帮助我解决该问题?
我是 spring 和 lombok 的新手。我正在为该方法使用的控制器进行单元测试@AuthenticationPrincipal。根据我的阅读,它将经过身份验证的用户的信息传递到方法中。有没有办法在单元测试中模拟这个?
java ×5
keycloak ×2
spring ×2
admob ×1
android ×1
aws-cli ×1
base64 ×1
escaping ×1
expo ×1
gradle ×1
html ×1
jackson ×1
javascript ×1
kotlin ×1
lombok ×1
maven ×1
react-native ×1
reactjs ×1
rx-android ×1
rx-java2 ×1
sealed-class ×1
spring-boot ×1
unit-testing ×1
userinfo ×1
xml ×1