我创建了一些JAX-RS 2.0资源(使用在Servlet容器中运行的Jeresey 2.4)和一个处理身份验证和授权的过滤器,可以通过@NameBinding注释有选择地应用.一切都很好.
我希望能够在此注释上定义一些参数(特别是访问每个方法/资源所需的安全权限),这些参数在运行时可用于过滤器以改变此行为.
我注意到拦截器可以通过javax.ws.rs.ext.InterceptorContext.getAnnotations()执行此操作,但是javax.ws.rs.container.ContainerRequestContext中没有等效的过滤器.有什么想法可以实现吗?我希望能够做类似以下的事情:
@Target({TYPE, METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
@NameBinding
public @interface Secured {
String[] requiredPermissions() default {};
}
@Secured
@Priority(Priorities.AUTHENTICATION)
public class SecurityRequestFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
// extract credentials, verify them and check that the user has required permissions, aborting if not
}
}
@Path("/userConfiguration/")
public class UserConfigurationResource {
@GET
@Produces(MediaType.APPLICATION_XML)
@Secured(requiredPermissions = {"configuration-permission"})
public Response getConfig(@Context HttpServletRequest httpServletRequest) {
// produce a response
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试迁移稳定的app服务器,以便从Spring Cloud Config服务器获取配置.每个应用程序{my-app}.yml在配置服务器上都有一个文件,我们可以使用配置文件(在名为{my-app}-{profile}.yml或使用多配置文件的YAML文档的文件中)为每个应用程序的每个环境配置不同的配置,我们甚至可以在另一个应用程序中包含一个配置文件spring.profiles.include用于提供一些继承 - 到目前为止,这么好.
但是,我们只能包含来自同一个应用程序的配置文件,并且我们有几个应用程序从同一配置服务器配置,每个环境共享大量配置 - 例如,他们几乎都使用相同的DataSource配置连接到同一个数据库同样用于消息传递,缓存等.这是很多重复的配置和许多需要更改的地方 - 正是Spring Cloud Config应该避免的!
有没有办法在Spring Cloud Config服务器中的应用程序之间 "包含"(通过配置文件或其他方式!)共享配置属性?
更新
除了以下@vladsfl的正确答案之外,请注意如果您使用配置服务器上的本机配置文件来从文件系统或类路径而不是git repo提供配置,配置服务器将使用application.yml及其配置文件变体对于自己,但拒绝将其提供给其他应用程序.解决方案是用于spring.cloud.config.server.native.searchLocations从不同位置提取服务配置.
我正在寻找一种方法来设置现有的git存储库(从Atlassian存储上托管的中央存储库克隆),以便从specfic分支的更改同步到SVN存储库上的路径.我对从SVN获取更改或同步分支和标记不是特别感兴趣; 我只想拥有一个SVN"镜像"我的一个分支.
在阅读git-svn手册页和其他各种来源后,我得到了使用git svn init设置svn repo,但是它会拒绝提交任何内容:
$ git --version
git version 1.9.5.msysgit.0
$ git clone ssh://git@stash-server.mydomain.com:4321/myproject/playground.git
Cloning into 'playground'...
$ cd playground
$ svn mkdir --parents https://svn-server.mydomain.com:5432/svn/playground/trunk -m "Importing git repo"
Committed revision 15900.
$ git svn init https://svn-server.mydomain.com:5432/svn/playground/trunk
$ git svn fetch
W: Ignoring error from SVN, path probably does not exist: (175007): HTTP Path Not Found: REPORT request failed on '/svn/145273/!svn/bc/100/playground/trunk': '/svn/145273/!svn/bc/100/playground/trunk' path not found
W: Do not be alarmed at the above message git-svn is just searching …Run Code Online (Sandbox Code Playgroud) java ×2
git ×1
git-svn ×1
jax-rs ×1
jersey ×1
rest ×1
spring ×1
spring-boot ×1
spring-cloud ×1
svn ×1