我想使用maven发布插件发布一个快照项目'foo-1.0-SNAPSHOT'.该项目取决于尚未发布的第三方模块"bar-1.0-SNAPSHOT".我在项目的pom.xml中使用选项'allowTimestampedSnapshots'来允许带时间戳的快照,但我认为第三方模块(bar)没有时间戳,除非我自己构建它,因为maven仍抱怨未解决的SNAPSHOT依赖项.
有没有办法释放项目foo,无论依赖SNAPSHOT项目如何,如果不是,我怎么能为第三方项目添加时间戳?
使用oAuth 2.0,在"授权代码"授权授权中,我首先调用"/ authorize",获取代码,然后在调用"/ token"时使用此代码来获取访问令牌.
我的问题:为什么这是流程?我想这是出于安全原因,但我无法弄明白.为什么实现是这样的,并且在第一次调用("/ authorize")之后没有立即获取访问令牌?
为什么我们需要这个代码?
当开发人员想要保护他的Web应用程序时,Spring Security非常棒.
但是,创建帐户怎么样?和"忘记密码"?大多数登录页面都有这些链接以及用户名和密码字段.Spring的默认登录页面没有这些链接......在好的情况下,它可以支持"记住我"......
Spring是否支持这些流程,创建帐户,忘记密码和更改密码?如果答案是肯定的,你能指点我一些文件吗?
我搜索过这个问题却找不到任何东西.
谢谢!
authentication spring registration change-password forgot-password
我在SO上发现了很多关于这个主题的问题,但是找不到任何回答这个问题的问题:
我应该使用用户名和密码,还是使用API密钥验证用户?每种方法的优缺点是什么?
我问这个是因为在我的API中,有几种方法我想锁定并验证用户是否可以访问某些文档或操作.我有点不愿意通过让用户使用他们的用户名和密码发送HTTP AUTH标头进行身份验证,因为它感觉不安全并且对用户来说更麻烦.另一方面,如果我使用API密钥,那么用户创建密码的重点是什么?因为他们将不再使用它来访问API的功能.
UPDATE
如果其他读者对我最终使用的内容感到好奇,我决定复制亚马逊的验证方式(这里有很好的解释:https://www.ida.liu.se/~TDP024/labs/hmacarticle.pdf)
我发现很难进行密码恢复,因为我以前从未这样做过.
到目前为止,我的网络应用程序有:
Spring Security,其中正确地密码密码并实现用户角色并正常工作.
该策略暗示了stackoverflow的研究:
什么是未知的:
正如您所看到的,对于单个问题,列表非常严重.因此希望您能够提供指导资源,以便逐步完成.我有点惊讶我在Spring Security文档中找不到这个.谢谢.
我是学生,所以不知道这样做的行业最佳实践,尤其是在Java环境中,所以我真的希望任何人都能提供帮助.
我在https://github.com/royclarkson/spring-rest-service-oauth上找到了关于Spring REST Service OAuth的教程
但我想知道如何配置存储到数据库的客户端,所以我可以轻松管理.在课程OAuth2ServerConfiguration.java中的教程客户端配置存储inMemory中
@Override
public void configure(ClientDetailsServiceConfigurer clients)
throws Exception {
// @formatter:off
clients.inMemory().withClient("clientapp")
.authorizedGrantTypes("password", "refresh_token")
.authorities("USER").scopes("read", "write")
.resourceIds(RESOURCE_ID).secret("123456");
// @formatter:on
}
Run Code Online (Sandbox Code Playgroud) 我已按照此处的指南将 JAR 文件安装到我的本地存储库中。
我运行以下命令:
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=log4j-weblayout-0.0.1-SNAPSHOT.jar
Run Code Online (Sandbox Code Playgroud)
JAR 文件是使用 Maven 构建的,其中包含一个 POM 文件,其中列出了其依赖项。JAR 中的文件具有以下路径:
/META-INF/maven/in.ksharma/log4j-weblayout/pom.xml
Run Code Online (Sandbox Code Playgroud)
Maven 安装工件但不读取其 POM。它创建一个空的 POM 文件,该文件没有任何依赖信息:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>in.ksharma</groupId>
<artifactId>log4j-weblayout</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>POM was created from install:install-file</description>
</project>
Run Code Online (Sandbox Code Playgroud)
如何确保 JAR 中的 POM 是已安装的那个?
编辑:
JAR 中各种文件的内容如下。
/META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: kshitiz
Created-By: Apache Maven 3.1.0
Build-Jdk: 1.8.0
Run Code Online (Sandbox Code Playgroud)
/META-INF/maven/in.ksharma/log4j-weblayout/pom.properties:
#Generated by Maven
#Wed Oct 08 19:48:28 IST 2014
version=0.0.1-SNAPSHOT
groupId=in.ksharma
artifactId=log4j-weblayout
Run Code Online (Sandbox Code Playgroud)
/META-INF/maven/in.ksharma/log4j-weblayout/pom.xml:
<project …Run Code Online (Sandbox Code Playgroud) 我在这里搜索了一下,但找不到我的问题的答案.
我使用spring-sec-oAuth 2.0(1.0.0.RC2a)实现oAuth客户端.正确设置beans.xml后,我很高兴得到一个有效的令牌,所有看起来都很好.然后,我想使用Calendar API - 我不知道如何调用以获取Calendar对象.
我的(相关)设置:(spring-servlet.xml)
<!--apply the oauth client context-->
<oauth:client id="oauth2ClientFilter" />
<oauth:resource id="google"
type="authorization_code"
client-id="<my client id>"
client-secret="<my client secret>"
access-token-uri="https://accounts.google.com/o/oauth2/token"
user-authorization-uri="https://accounts.google.com/o/oauth2/auth"
scope="https://www.googleapis.com/auth/calendar"
client-authentication-scheme="form"
pre-established-redirect-uri="https://ohad.sealdoc.com/oauth2-client/hello" />
<bean id="googleClientService" class="com...GoogleClientServiceImpl">
<property name="butkeDemoRestTemplate">
<oauth:rest-template resource="google" />
</property>
Run Code Online (Sandbox Code Playgroud)
和实现类:
public class GoogleClientServiceImpl implements DemoService
{
private RestOperations butkeDemoRestTemplate;
@Override
public String getTrustedMessage()
{
String dataUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer";
Calendar service = butkeDemoRestTemplate.getForObject(dataUri, Calendar.class);
return "demo";
}
}
Run Code Online (Sandbox Code Playgroud)
这样做最终得到:
请求处理失败; 嵌套异常是error ="invalid_request",error_description ="{errors = [{domain = usageLimits,reason = accessNotConfigured,message …
在用户使用Spring Security初次登录时,实现强制密码更改的最优雅方法是什么?
我尝试实现这里AuthenticationSuccessHandler提到的自定义,但正如rodrigoap所提到的,如果用户在地址栏手动输入URL,即使用户没有更改密码,用户仍然可以继续访问该页面.
我用过滤器ForceChangePasswordFilter做了这个.因为如果用户手动键入url,他们可以绕过更改密码表单.使用过滤器,请求始终被截获.
因此,我继续实施自定义过滤器.
我的问题是,当我实现一个自定义过滤器和发送里面重定向,它会通过过滤器再次提到引起无限重定向循环这里.我尝试通过在security-context.xml中声明两个http标签来实现所提到的解决方案,第一个标签具有pattern属性,但它仍然通过我的自定义过滤器:
<http pattern="/resources" security="none"/>
<http use-expressions="true" once-per-request="false"
auto-config="true">
<intercept-url pattern="/soapServices/**" access="permitAll" requires-channel="https"/>
...
<custom-filter position="LAST" ref="passwordChangeFilter" />
</http>
...
<beans:bean id="passwordChangeFilter"
class="my.package.ForcePasswordChangeFilter"/>
<beans:bean id="customAuthenticationSuccessHandler"
class="my.package.CustomAuthenticationSuccessHandler" >
</beans:bean>
<beans:bean id="customAuthenticationFailureHandler"
class="my.package.CustomAuthenticationFailureHandler" >
<beans:property name="defaultFailureUrl" value="/login"/>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
我当前的实现(有效)是:
isFirstLoginisFirstLogin是否已设置
chain.doFilter()我对此实现的问题是访问我的资源文件夹也会通过此过滤器导致我的页面失真(因为*.js和*.css未成功检索).这就是我<http>在我的安全应用程序context.xml中尝试使用两个标签的原因(这不起作用).
因此,如果servletPath启动或包含"/ resources",我最终必须手动过滤请求.我不希望它像这样 - 必须手动过滤请求路径 - 但现在它就是我拥有的.
这样做的优雅方式是什么?
这是我的课,
public class MyBusinessException extends RuntimeException {
@Autowired
private MessageSource messageSource;
private String errorCode;
private String messageInEnglish;
public MyBusinessException(String errorCode){
this.errorCode=errorCode;
this.messageInEnglish=messageSource.getMessage(this.code,null, Locale.ENGLISH);
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个异常类。当我将它errorCode作为参数传递给构造函数时,它应该填充错误消息,这就是我要寻找的。事实上,我想像这样实例化类
throw new MyBusinessException("MY-ERROR-CODE");//want to initiate like this(only one argument for constructor)
Run Code Online (Sandbox Code Playgroud)
如何实现这样的目标?
到目前为止,我已经尝试了所有这些:
@PostConstruct我设置了我的tomcat服务器,它可以在LOCAL-HOST上运行,但是我不能在外部运行它.我必须更改一些设置吗?我尝试了所有的东西,但它似乎没有工作在其他地方......这很奇怪,因为它在本地主机上运行得非常好.
我有一个gradle项目,Artifactory作为存储库.
我对文档有点疑惑,所以我请问专家:将工件上传到Artifactory的首选方法是什么?使用gradle'suploadArchives或Artifactory's artifactoryPublish?
为什么uploadArchives还不够?
java ×3
oauth-2.0 ×3
spring ×3
maven ×2
spring-mvc ×2
annotations ×1
api ×1
artifactory ×1
google-api ×1
gradle ×1
maven-2 ×1
maven-3 ×1
pom.xml ×1
registration ×1
release ×1
rest ×1
server ×1
snapshot ×1
spring-boot ×1
tomcat ×1
versioning ×1