我正在尝试使用简单的Spring OAuth2 SSO应用程序,但我无法这样做.以下是发生的事情的步骤和结果:
/user,由OAuth2保护然后,我在OAuth2 SSO应用程序上获得了一个白标错误页面,其中包含以下内容:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Jul 13 08:19:18 EDT 2015
There was an unexpected error (type=Unauthorized, status=401).
Authentication Failed: Could not obtain access token
Run Code Online (Sandbox Code Playgroud)授权码位于URL中.以下是示例网址:
http://localhost:8083/login?code=9s63rU&state=Fo9S2M
Run Code Online (Sandbox Code Playgroud)
我没有看到HTTP POST授权服务器/oauth/token端点获取JWT.我通过/trace授权服务器上的端点验证了这一点.
异常堆栈是:
2015-07-13 08:23:32.695 DEBUG 3516 --- [nio-8083-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/login'; against '/css/**'
2015-07-13 08:23:32.695 …Run Code Online (Sandbox Code Playgroud) spring spring-security spring-boot spring-security-oauth2 spring-cloud
我正在使用Spring Boot 1.2.1并尝试@ConfigurationProperties使用如下验证创建一个bean:
package com.sampleapp;
import java.net.URL;
import javax.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties
public class SampleAppProperties {
@NotNull
private URL url;
public URL getUrl() {
return url;
}
}
Run Code Online (Sandbox Code Playgroud)
引导应用程序的类是:
package com.sampleapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
@SpringBootApplication
@EnableConfigurationProperties
public class SampleApplication implements EnvironmentAware {
private static Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
@Override
public void setEnvironment(Environment environment) {
LOGGER.info("URL …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Boot 1.2.3,我想了解是否可以在将属性值注入带注释的bean之前对其进行解密@ConfigurationProperties.
假设我在application.properties文件中有以下内容:
appprops.encryptedProperty=ENC(ENCRYPTEDVALUE)
和这样的示例应用程序:
package aaa.bb.ccc.propertyresearch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import javax.annotation.PostConstruct;
@SpringBootApplication
@EnableConfigurationProperties(PropertyResearchApplication.ApplicationProperties.class)
public class PropertyResearchApplication {
public static void main(String[] args) {
SpringApplication.run(PropertyResearchApplication.class, args);
}
@ConfigurationProperties("appprops")
public static class ApplicationProperties {
private String encryptedProperty;
@PostConstruct
public void postConstruct() throws Exception {
System.out.println("ApplicationProperties --> appprops.encryptedProperty = " + encryptedProperty);
}
public String getEncryptedProperty() {
return encryptedProperty;
}
public void setEncryptedProperty(String encryptedProperty) {
this.encryptedProperty = encryptedProperty;
}
}
} …Run Code Online (Sandbox Code Playgroud) 我正在寻找使用 Spring Boot 实现一个简单的反向代理,即:
我查看了注释提供的功能@EnableZuulProxy,但它似乎太重量级了,因为我不想使用 Eureka、Ribbon 或 Hystrix。然而,@EnableZuulServer配置有点轻。
有人能提供一个我所追求的例子吗?Netflix Zuul 是正确的选择吗?还是还有其他我应该考虑的库?
谢谢!