如何在ServiceStack中使用自定义身份验证路由实现注销

时间:2013-09-19 10:53:13

标签: c# authentication servicestack

简单的问题,我已经得到了以下代码,使用自定义CredentialsAuthProvider指定用户身份验证的路由(使用我在文档中找到的内容放在一起)

// inside 'Configure()'....
Dictionary<Type, string[]> serviceRoutes = new Dictionary<Type, string[]>();
serviceRoutes.Add(typeof(AuthService), new[] { "/user/auth" });           
AuthFeature authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
    new myCompany.web.JSONService.myCompanyCredentialsAuthProvider() 
});
authFeature.IncludeAssignRoleServices = false;
authFeature.ServiceRoutes = serviceRoutes; //specify manual auth routes            
Plugins.Add(authFeature);

创建了/ user / auth的路由,我也喜欢这样的路由:

/user/logout

但是关于注销功能的文档很少。这是一个自定义路由,我必须像我所有的其他API调用一样构建到我的服务中,或者我可以使用配置选项吗?

另外,我目前正在使用swagger插件来记录和测试我的服务,但它显示/user/auth路由为'get',我想将其限制为'post'动词,如果那可能吗?次要问题,主要是想知道实施注销的正确方法

1 个答案:

答案 0 :(得分:1)

AuthFeature/auth/logout创建一条路线,你可以点击GET或POST来注销

相关问题