问题标签 [spring-security-rest]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
774 浏览

rest - Spring security rest 插件:基于令牌的身份验证

我正在尝试成功集成Spring 安全休息插件

但我经常失败,我正在使用 memcahed 进行令牌存储。我用来实现插件的 Config.groovy 设置是:

/api/login我通过Post man rest client提出请求

json数据,但它给了我spring security auth page的html作为响应,我做错了配置吗?是否需要任何进一步的配置。我提到我正在使用memcache进行令牌存储。任何想法都会对我有所帮助。

编辑:请查看日志文件

Edit2:请检查此日志文件

0 投票
1 回答
1559 浏览

rest - Spring security rest plugin: Authentication failed, No AuthenticationProvider found

I am trying to integrate spring security rest plugin version 1.4.1 in my grails app, but facing some issue, I am doing like that:

Config.groovy setting:

and

As you can see from setting I am using Memcache for token storage, when I hit the url api/login via a rest client I got 401 I enabled the logs In which it says that Authentication provider not found

Here is the logs:

My another point is that: If I make a request like localhost:8080/restspring/api/guest/controller/action (for non-authenticated request) do I need to do some entry in URL mapping for this?My application uses the custom authentication provider. Any idea will be helpful for me, thanks.

0 投票
2 回答
814 浏览

rest - 禁用 RestAuthenticationFilter - Grails Spring Security Rest 插件

我正在使用带有 spring-security-rest、spring-security-core 和 spring-security-ui 插件的 Grails v2.4.2。

我正在尝试禁用 spring-security-rest 附带的 RestAuthenticationFilter ,以便我可以编写一个不区分大小写的自定义身份验证过滤器。

在我的 config.groovy 中,我使用了以下过滤器链图:

]

我添加了“- restAuthenticationFilter ”以排除 RestAuthenticationFilter 但它仍在运行。

在通过 RestAuthenticationFilter 登录时,如何排除 RestAuthentication Filter 或者是否有更简单的方法可以为用户名添加不区分大小写的功能?

0 投票
0 回答
1115 浏览

rest - Grails + Spring Security Rest,发出 POST 请求

我能够登录(/api/login)并且能够成功发出 GET 请求。但是,我似乎无法弄清楚如何发出 POST 请求,同样我也无法注销 (/api/logout)。

控制器:(com.example.test)

卷曲登录(和 HTTP 响应):

GET 请求的卷曲(方法秘密的示例):

我的 POST 请求总是导致被重定向到登录页面(即使我传递了令牌)。请展示如何使用 curl 或类似休息客户端(邮递员)的方式进行发布请求的示例。如果可能,请显示如何注销 (/api/logout)

配置
grails.plugin.springsecurity.rest.login.active=true grails.plugin.springsecurity.rest.login.endpointUrl='/api/login' grails.plugin.springsecurity.rest.login.failureStatusCode=401 grails.plugin.springsecurity. rest.login.useJsonCredentials=true grails.plugin.springsecurity.rest.login.usernamePropertyName='用户名' grails.plugin.springsecurity.rest.login.passwordPropertyName='密码' grails.plugin.springsecurity.rest.logout.endpointUrl=' /api/logout' grails.plugin.springsecurity.rest.token.storage.useGorm = true grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName="com.example.AuthenticationToken" grails.plugin.springsecurity.rest .token.storage.gorm.tokenValuePropertyName="tokenValue" grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName='username'grails.plugin.springsecurity.rest.login.usernamePropertyName='用户名' grails.plugin.springsecurity.rest.login.passwordPropertyName='密码' grails.plugin.springsecurity.rest.token.generation.useSecureRandom = true

尝试使用 POST 失败

以下是我尝试使用 Curl 和邮递员的一些方法:


并且还使用邮递员(POST 注销附图):

0 投票
1 回答
479 浏览

rest - spring-security-rest 插件注销失败

我正在使用spring-security-rest:1.5.0.RC2和 Grails 2.5.0。我为用户配置文件信息 UserProfileController 创建了一个控制器,它扩展了 RestfulController。登录工作正常以及检索用户配置文件。但是,当我尝试 \api\logout 我得到

注销时,我指定了 Bearer 令牌,以便它正确地找到用户,但它似乎想使用静态规则来确定是否允许访问注销页面,并且如果断定访问被拒绝,它就找不到规则。这是由于最近版本的 grails 中引入的页面的悲观锁定。请参阅下面的日志。

我在 Config.groovy 中的 controllerAnnotations.staticRules 没有指定任何 \api**

我的 filterChain.chainMap 看起来像这样

实现它的控制器的注销方法上的安全注释是什么?我怎样才能使这项工作?

谢谢

0 投票
1 回答
475 浏览

spring - RESTful API 的 Spring Security

我正在使用 Spring 4.1.6 和spring-boot-starter-data-rest.

为了使其余的 api 功能齐全,我需要最后一块拼图:安全性。现在我注意到 spring 有它自己的spring-security-*包可以帮助完成这项任务。

我尝试使用spring-security-configandspring-security-web它就像一个魅力,除了如果用户未通过身份验证,spring 会将用户重定向到登录,从而提供 HTML 登录表单。因为它是一个 Restful API,所以如果用户缺少凭据或没有足够的权限来读取特定资源,我只需要在 JSON 对象中返回一个错误。我敢肯定我不是第一个提出这个问题的人,我在网上搜索了问同样问题的人,但找不到我正在寻找的东西。那么..我应该继续使用spring-security在这个方向上进行研究,还是应该找到一些东西?

欢迎任何建议,谢谢

0 投票
2 回答
738 浏览

grails - 使用 Grails Spring Security REST 插件进行身份验证

我遇到了 Alvaro 的 Greach 2014 演示文稿。我从 GitHub 下载了示例并启动它。

当我尝试进行身份验证时

我在卷曲方面得到了这个。

在服务器端,我看到了。

请求中未发送 JSON 正文。我如何使用 cURL 发送这个?

或者为什么它不接我的

0 投票
1 回答
4302 浏览

grails - 带有自定义 X-Auth-Token 标头的 cURL 请求重定向到登录页面

我正在使用 Alvaro 的 greach2014 存储库来试验 Spring Security Rest 插件的行为。我可以登录应用程序并生成身份验证令牌。但是,当我尝试发送获取请求时,我被重定向到登录页面。这是我的 cURL 回复

curl -X GET -i -H "X-Auth-Token: Bearer 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "Accept: application/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories HTTP/1.1 302 Found Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=7D36AB88B14828CDB7085BBB8722A35F; Path=/restful-grails-springsecurity-greach2014/; HttpOnly Location: http://localhost:8080/restful-grails-springsecurity-greach2014/login/auth Content-Length: 0 Date: Tue, 07 Jul 2015 05:59:16 GMT

我也尝试过使用 Bearer 标志,但结果是一样的

curl -X GET -i -H "X-Auth-Token: Bearer 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "Accept: application/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories

同样,我也尝试过 Authorization Bearer 标头,但它导致超时异常:

``` curl -X GET -i -H "授权:承载 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "接受:应用程序/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories HTTP/1.1 500 内部服务器错误服务器:Apache-Coyote/1.1 内容类型:text/html;charset=utf-8 内容语言:en 内容长度:4472 日期:星期二,2015 年 7 月 7 日 05:59:46 GMT 连接:关闭

Apache Tomcat/7.0.52 - 错误报告

HTTP 状态 500 - 等待值超时

类型异常报告

消息超时等待值

描述服务器遇到一个内部错误,阻止它完成这个请求。

例外

p>

根本原因

p>

note Apache Tomcat/7.0.52 日志中提供了根本原因的完整堆栈跟踪。

Apache Tomcat/7.0.52

0 投票
2 回答
2354 浏览

grails - 如何自定义 Grails Spring Security REST 登录响应 HTTP 代码

我正在为 Grails 应用程序使用 Spring Security 插件和 Spring Security REST 插件,并尝试实施密码更改策略。在前端,当您未登录时,我们的应用程序会捕获 401 错误,但您的密码已过期的情况会给出完全相同的 HTTP 响应。我正在寻找是否有办法改变它。

我可以捕获 AbstractAuthenticationFailureEvent 并确定它是否是由于 AuthenticationFailureCredentialsExpired 事件造成的,但我不知道如何让该事件从 API 中发送任何有意义的信息,表明这不仅仅是密码登录失败。

顺便说一句,我可以使密码过期并执行该策略,所以这不是问题。主要问题是此 API 的使用者如何区分失败的用户名/密码质询和“您需要更改密码”场景。

0 投票
1 回答
488 浏览

rest - 使用 Grails Spring Security Rest 插件时如何获取客户端登录失败的原因?

我们将 Grails Spring Security Rest 插件 1.5.2 与 Grails 2.5.2 一起使用。

不幸的是,它似乎没有报告发生登录失败的任何原因。我们从登录请求中得到的唯一信息是HTTP 401.

我们有一种机制,在多次登录失败后,我们设置 的accountLocked属性User,因此帐户被禁用/锁定。

我们希望至少获得一个关于登录失败原因的 JSON 响应,例如“用户帐户被锁定”、“凭据错误”、“没有这样的用户”等。

有没有办法用我们使用的当前版本来做到这一点?