【问题标题】:Authentication and Authorization with ServiceStack.MVC使用 ServiceStack.MVC 进行身份验证和授权
【发布时间】:2012-06-29 12:08:41
【问题描述】:

AuthorizeAttribute 在使用 ServiceStack.Mvc 时没用

AuthenticateAttribute 用于 DTO 对象。

没有带有 ServiceStack 的 AccountController 示例,Signout 在 SocialBootStrapApi 中不起作用。

ServiceStack.Mvc 的基本 Login、Logout、Authorize with Roles 示例在哪里? (不是单页应用,经典的 Asp.Net Mvc)

【问题讨论】:

    标签: asp.net-mvc authentication authorization servicestack


    【解决方案1】:

    ServiceStack 不使用 ASP.NET 或 MVC 的身份验证或任何依赖它的东西,例如MVC的AccountController,它使用自己的Authentication Provider。

    AuthenticateAttribute 和任何其他 ServiceStack Request or Response Filter attributes 实际上可以在 DTO 和服务上使用。

    如果您从ServiceStackController 继承,那么您可以在[ExecuteServiceStackFilters] 中使用ServiceStack 的属性过滤器来执行,例如

    • [认证]
    • [必需角色]
    • [必需权限]

    【讨论】:

    • 两个问题:当我在基类中使用 Authenticate attibute 时它不起作用。登录网址是硬编码的,我该如何覆盖它stackoverflow.com/questions/11301790/…
    • 你的基类是否继承了ServiceStackController?
    • XController继承自YController(YController有AuthenticateAttribute),YController继承自BaseController:ServiceStackController
    • 总结。 XController:YController(有认证属性):BaseController:ServiceStackController :)
    • 在 XController,BaseController 上正常。但是在 YController 上它不起作用。
    猜你喜欢
    • 1970-01-01
    • 2016-07-30
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 2017-05-10
    • 1970-01-01
    • 2012-12-12
    • 2021-06-05
    相关资源
    最近更新 更多