小编Ken*_*ger的帖子

@ EnableOAuth2Sso - 如何保护/取消保护资源?

我正在尝试在Spring Cloud Security中使用@ EnableOAuth2Sso功能.具体来说,我试图用OAuth2保护一些资源,同时让其他资源公开访问.我已经设法让这个工作,但我正在查看生成的代码,并想知道是否有一个更清洁的方式.

我在这里关注文档:https: //github.com/spring-cloud/spring-cloud-security/blob/master/src/main/asciidoc/spring-cloud-security.adoc和Spring Boot的类似指导参考.我有一个很小的代码示例,说明了我的困境:https: //github.com/kennyk65/oAuthSsoExample.

简而言之,我希望localhost:8080 /不受保护的资源是公开可用的,我希望localhost:8080/protected资源需要OAuth2(通过github,如配置的那样).我能够使基本的OAuth2行为正常工作,但导致/不受保护的公开可用是有问题的.

首先,文档表明您可以使用OAuth2SsoConfigurer的match()方法来指定要保护的资源.我发现这不起作用; 当我尝试时,我得到一个IllegalStateException,说至少需要一个映射.这似乎是指未实现的configure(HttpSecurity)方法.

接下来,我尝试在configure(HttpSecurity)中指定一个映射,指出"不受保护的"资源应该是不受保护的.但是,这会导致将Http基本安全性应用于该资源.奇怪的是,这导致"受保护"资源完全公开!

// This results in “unprotected” being protected by HTTP Basic
// and “protected” being completely open!   
@Configuration
protected static class OauthConfig extends OAuth2SsoConfigurerAdapter {
  @Override
  public void match(RequestMatchers matchers) {
    matchers.antMatchers("/protected/**");
  }

  @Override
  public void configure(HttpSecurity http) throws Exception {
    http
      .authorizeRequests()
        .antMatchers("/unprotected/**").permitAll();        
  }
}
Run Code Online (Sandbox Code Playgroud)

我一时兴起,故意添加受保护资源的身份验证.这导致受保护的资源获得OAuth2保护(欢呼!)但是未受保护的资源应用了http基本安全性(呵呵?).

// This results in “protected” being protected by OAuth 2
// and “unprotected” being protected …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot spring-security-oauth2 spring-cloud

5
推荐指数
1
解决办法
3170
查看次数

Amazon S3 选择不工作

Amazon S3 有一项新功能select from,允许对简单数据文件(例如 CSV 或 JSON)运行简单 SQL 查询。所以我想我会尝试一下。

我创建了以下 CSV 并将其上传到我位于俄勒冈州的 S3 存储桶(我认为这个文件非常简单):

aaa,bbb,ccc
111,111,111
222,222,222
333,333,333
Run Code Online (Sandbox Code Playgroud)

我指出这是带有标题行的 CSV,并发出以下 SQL:

从 s3object s 选择 *

...按预期工作,返回:

111,111,111
222,222,222
333,333,333
Run Code Online (Sandbox Code Playgroud)

然后我尝试了提供的示例查询之一,但失败了:

select s._1, s._2 from s3object s
Run Code Online (Sandbox Code Playgroud)

...错误消息是“文件中缺少查询中的某些标头。请检查文件并重试。”。

还尝试了以下方法,每次都会收到相同的错误:

select aaa from s3object s
select s.aaa from s3object s
select * from s3object s where aaa = 111
select * from s3object s where s.aaa = 111
select * from s3object s where s._1 = 111
Run Code Online (Sandbox Code Playgroud)

因此,每当我的查询在 SELECT …

sql csv amazon-s3 amazon-web-services amazon-s3-select

5
推荐指数
1
解决办法
9804
查看次数

Spring Cloud Turbine - 无法处理多个客户端?

让Turbine在Spring Cloud中工作我遇到了一些麻烦.简而言之,我无法确定如何配置它以一次聚合来自多个应用程序的电路.

我有6个独立的服务,一个eureka服务器和一个以独立模式运行的涡轮服务器.我可以从我的Eureka服务器上看到所有服务都已注册,包括涡轮机.我的涡轮机服务器已启动并运行,我可以看到它的/ hystrix页面没有问题.但是当我尝试用它来检查turbine.stream时,我只看到了在turb.appConfig中列出的FIRST服务器,其余的都被忽略了.

这是我的Turbine服务器的application.yml,或者至少是相关部分:

---
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8010/eureka/
server:
  port: 8030
info:
  component: Turbine
turbine:
  clusterNameExpression: new String(“default”)
  appConfig: sentence,subject,verb,article,adjective,noun
management:
  port: 8990  
Run Code Online (Sandbox Code Playgroud)

当我运行这个并访问我的涡轮机实例上的hystrix仪表板,询问turb.stream时,输出中列出的ONLY断路器是appConfig中列出的第一个服务,在这种情况下是"句子"服务.奇怪的是,如果我重新安排这些服务的顺序并先放入另一个服务(比如"名词"),我只会看到那些服务的电路.仅显示列表中的第一个服务.

我承认在一些术语上有点困惑,比如流,集群等,所以我可能会遗漏一些基本概念,但我的理解是Turbine可以从多个服务中消化流并聚合它们在一个显示器中.建议将不胜感激.

turbine spring-boot hystrix spring-cloud

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