小编Tat*_*tha的帖子

Spring Boot 中的多个 WebSecurityConfigurerAdapter 用于多种模式

我正在尝试为我的项目设置多个 WebsecurityConfigurerAdapter,其中 Spring Boot 执行器 API 使用基本身份验证进行保护,所有其他端点使用 JWtAuthentication 进行身份验证。我只是无法让它一起工作,只有较低顺序的配置才能工作。我正在使用 Spring Boot 2.1.5.RELEASE

带有 JWT 身份验证器的安全配置一

@Order(1)
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    private static final String[] AUTH_WHITELIST = {
        "/docs/**",
        "/csrf/**",
        "/webjars/**",
        "/**swagger**/**",
        "/swagger-resources",
        "/swagger-resources/**",
        "/v2/api-docs"
};

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
            .antMatchers(AUTH_WHITELIST).permitAll()
            .antMatchers("/abc/**", "/abc/pdf/**").hasAuthority("ABC")
            .antMatchers("/ddd/**").hasAuthority("DDD")
            .and()
            .csrf().disable()
            .oauth2ResourceServer().jwt().jwtAuthenticationConverter(new GrantedAuthoritiesExtractor());
   }
}
Run Code Online (Sandbox Code Playgroud)

带有用户名/密码的基本身份验证配置

@Order(2)
@Configuration
public class ActuatorSecurityConfig extends WebSecurityConfigurerAdapter {

/*    @Bean
public UserDetailsService userDetailsService(final PasswordEncoder encoder) {
    final InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot

14
推荐指数
1
解决办法
7520
查看次数

API开发平台(例如APIGEE和ESB)之间的差异

我和我的团队将致力于APIGEE,这是一个API开发平台,可以在我们的应用程序中公开一些服务.我正在阅读他们的文档,并试图了解APIGEE或任何其他API开发平台(如Mashery)的需求.关于API代理需求的一篇非常好的文章在给定链接中得到了很好的解释,http://apievangelist.com/2011/06/11/the-battle-for-your-api-proxy/

我感到困惑的一个问题是APIGEE与任何ESB如ALSB或Mule之间什么区别.我们知道Apigee也支持通过http/https/soap等策略和协议进行消息转换.

谁能告诉我两者之间的区别?Esb是否支持更多协议,如SMTP/JMS等.

任何信息都是最受欢迎的

api-design esb mashery apigee

11
推荐指数
1
解决办法
2万
查看次数

在Amazon Quicksight中安排报告和数据驱动的警报

我正在探索Amazon Quicksight作为基于云的BI工具.我们有一些很好的要求

  1. 每月在同一组数据集上安排报告.这需要在特定日期每月向目标受众提供
  2. 数据驱动的警报,基于某些触发器,需要生成警报.
  3. 双轴条形图,用于一个图表中的多个度量.(Tableau有它)

我在文档中找不到上述三个功能.我相信QuickSight目前无法做到这一点.如果我错了,请纠正我.

这是一个快速团队在其管道中的东西吗?

-Tatha

amazon-web-services amazon-quicksight

8
推荐指数
1
解决办法
1269
查看次数

在 Keycloak 中测试/调试 javascript 映射器/策略的最佳方法

我是 Keycloak 的新手,一直在尝试设置基于 javascript 的 authz 策略和客户端映射器。我想知道调试此类映射器或策略的最佳方法是什么。

现在,如果脚本中有任何错误,我只能在服务器日志中找到它,但是有没有办法可以使用诸如 alert 或 console.log 之类的东西;在这两种情况下,服务器日志都提到:

Caused by: <eval>:18 ReferenceError: "alert" is not defined
Caused by: <eval>:18 ReferenceError: "console" is not defined 
Run Code Online (Sandbox Code Playgroud)

如果脚本运行时,如果我至少可以记录属性或属性的值以检查发生了什么,这将非常有帮助

jboss-tools wildfly keycloak keycloak-services

4
推荐指数
1
解决办法
2141
查看次数

在Spring Rest Docs中记录byte []响应

我正在构建一个API并使用Spring Rest Docs(1.1.1.RELEASE)对其进行文档记录,还有一个api以字节数组形式返回图像。

我需要在REST文档中描述响应类型。我不确定如何使用FieldDescriptor做到这一点

当我尝试:

//get mock byte array
byte[] attachment = "Hello".getBytes();

FieldDescriptor[] contentFields = new FieldDescriptor[] {
            fieldWithPath("").type(byte[].class)
                    .description("bytes of the attachment ")};

    when(serviceMock.getImage("fe329638007b4ea3b2a5")).thenReturn(attachment);

    this.mockMvc
            .perform(RestDocumentationRequestBuilders.get("/api/v1/contents/{contentId}/images", "fe329638007b4ea3b2a5"))
            .andExpect(status().isOk()).andDo(document("{method-name}",
                    pathParameters(parameterWithName("contentId").description("The id of the Content")),
                    responseFields(contentFields)));

    verify(serviceMock, times(1)).getImage("fe329638007b4ea3b2a5");
    verifyNoMoreInteractions(serviceMock);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

org.springframework.restdocs.payload.PayloadHandlingException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Hello': was expecting ('true', 'false' or 'null')
 at [Source: [B@13866865; line: 1, column: 11]
at org.springframework.restdocs.payload.JsonContentHandler.readContent(JsonContentHandler.java:86)
at org.springframework.restdocs.payload.JsonContentHandler.findMissingFields(JsonContentHandler.java:52)
at org.springframework.restdocs.payload.AbstractFieldsSnippet.validateFieldDocumentation(AbstractFieldsSnippet.java:152)
at org.springframework.restdocs.payload.AbstractFieldsSnippet.createModel(AbstractFieldsSnippet.java:100)
at org.springframework.restdocs.snippet.TemplatedSnippet.document(TemplatedSnippet.java:64)
at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:196)
at org.springframework.restdocs.mockmvc.RestDocumentationResultHandler.handle(RestDocumentationResultHandler.java:55)
at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:177)
at com.davita.comms.controller.CommsControllerTest.getThumbnailByContentId(CommsControllerTest.java:205)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-test spring-rest spring-restdocs

3
推荐指数
1
解决办法
1403
查看次数

在 Oracle Timestamp 列中以 UTC 格式保存日期

我需要将当前 UTC 日期与时间一起保存在 TIMESTAMP WITH TIMEZONE 类型的 Oracle 列中。这是来自带有 JPA 和 Hibernate 的 Spring Boot 服务

我在我的应用程序 yml 中启用了以下功能

  jpa:
    hibernate:
      ddl-auto: none
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.Oracle12cDialect
        jdbc:
          time_zone: UTC
Run Code Online (Sandbox Code Playgroud)

实体类字段看起来像

@Column(name = "last_user_edit_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private ZonedDateTime lastUserEditDate;
Run Code Online (Sandbox Code Playgroud)

在设置日期时我正在使用

obj.setLastUserEditDate(ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("UTC")));
Run Code Online (Sandbox Code Playgroud)

以上相对于实际日期值工作正常。唯一的问题是在数据库中它正在保存 UTC 时间,但提到 MST(我的本地时区)作为时区。例如,保存的值是

12-SEP-19 09.50.53.820000000 PM 美国/丹佛

这里的 9.50 PM 实际上是 UTC 时间,但时区是 AMERICA/DENVER。我想要的是

12-SEP-19 09.50.53.820000000 PM UTC

我怎样才能实现这个 Spring JPA 和 Java 8 类?

谢谢

oracle spring java-8 spring-data-jpa spring-boot

3
推荐指数
1
解决办法
2473
查看次数