Apache Shiro凭据基于Rest服务的安全性 [英] Apache Shiro credentials based security for Rest service

查看:249
本文介绍了Apache Shiro凭据基于Rest服务的安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Shiro作为安全框架创建一个App。
该应用程序有两个部分;网络和休息。

I'm creating a App using Shiro as the security framework. The app have two parts; Web and Rest.

网络正在使用Shiro的默认 FormAuthenticationFilter
我对基于会话的方法感到满意。

The Web is using Shiro's default FormAuthenticationFilter. I'm happy with the session based approach.

使用Rest的独立应用程序,我想限制使用 FormAuthenticationFilter 以及创建会话,我可以通过 shiro.ini 文件

The stand alone app which is using Rest, I want to limit from using the FormAuthenticationFilter and from creating a session, which I'm able to do via shiro.ini file

我需要在其余服务上实现基于凭据的安全性。

I need to implement credentials based security on the rest service.

在网上浏览我看到一些博客建议您创建自己的Realm并过滤到处理这种情况。但没有关于如何执行此操作的详细信息。

Browsing on the web I saw some blogs suggesting that you create your own Realm and filter to handle this scenario. But no details on how to do this.

是否可以在Apache Shiro上实施基于凭据的安全性?若有,那么博客或教程会告诉你如何实现这个目标?

Is it possible to implement credentials based security on Apache Shiro? If so is there a blog or tutorial that shows you how to achieve this?

问候

推荐答案

您可以使用基本身份验证为您的Web服务端点和基于表单的身份验证。

You could use basic auth for your webservice endpoints and form based authentication for the web.

网络用户是否也可以访问您的网络服务?

Do web users also have access to your webservice?

编辑:

查看此示例应用。 https://github.com/dominicfarr/skybird-shiro

它在shiro中配置了三个url路径。

It has three url paths configured in shiro.

web - 使用表单身份验证。

web - uses form authentication.

api - 使用基本身份验证。

api - uses basic authentication.

jersey - 匿名访问。

jersey - anonymous access.

切换到shiro.ini配置。

Cutting to the shiro.ini config.

[main]
authc.loginUrl = /web/login.html

sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO

securityManager.sessionManager = $sessionManager
securityManager.sessionManager.sessionDAO = $sessionDAO


[users]
dom = password, user

[roles]
user = standard

[urls]
/web/login.html = authc
/web/** = authc
/api/** = authcBasic
/jersey/message = anon

这篇关于Apache Shiro凭据基于Rest服务的安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆