问题
AuthorizeAttribute is useless while using ServiceStack.Mvc
AuthenticateAttribute is for DTO objects.
There is no sample for AccountController with ServiceStack, Signout is not working in SocialBootStrapApi.
Where is the basic Login,Logout,Authorize with Roles samples with ServiceStack.Mvc? (Not single page application, classic Asp.Net Mvc)
回答1:
ServiceStack doesn't use the ASP.NET's or MVC's Authentication or anything that relies on it e.g. MVC's AccountController, it uses its own Authentication Provider.
AuthenticateAttribute and any other ServiceStack Request or Response Filter attributes can in fact be used on both the DTO's and the Service.
If you inherit from ServiceStackController then you can use ServiceStack's Attribute Filters in [ExecuteServiceStackFilters] do get executed, e.g.
- [Authenticate]
- [RequiredRole]
- [RequiredPermission]
来源:https://stackoverflow.com/questions/11236728/authentication-and-authorization-with-servicestack-mvc