servicestack,restful-authentication,swagger-ui,Authentication,servicestack,Restful Authentication,Swagger Ui" /> servicestack,restful-authentication,swagger-ui,Authentication,servicestack,Restful Authentication,Swagger Ui" />

Authentication ServiceStack+;招摇过市-身份验证提供者

Authentication ServiceStack+;招摇过市-身份验证提供者,authentication,servicestack,restful-authentication,swagger-ui,Authentication,servicestack,Restful Authentication,Swagger Ui,如何在实现自定义身份验证提供程序(CredentialAuthProvider)时使用Swagger UI对ServiceStack进行身份验证 对于基本身份验证提供程序,我只需发送带有base64编码的user:password的授权头,但这如何?从v4.0.43+开始,现在,ServiceStack支持添加用户名和密码,每个招摇过市请求都会发送该密码,从而允许访问经过身份验证的服务: 这将使用BasicAuthProvider来启用身份验证,在注册AuthFeature时,可以通过该功能启

如何在实现自定义身份验证提供程序(CredentialAuthProvider)时使用Swagger UI对ServiceStack进行身份验证


对于基本身份验证提供程序,我只需发送带有base64编码的user:password的授权头,但这如何?

v4.0.43+开始,现在,ServiceStack支持添加
用户名
密码
,每个招摇过市请求都会发送该密码,从而允许访问经过身份验证的服务:

这将使用
BasicAuthProvider
来启用身份验证,在注册
AuthFeature
时,可以通过该功能启用身份验证:

Plugins.Add(new AuthFeature(...,
    new IAuthProvider[] {
        new BasicAuthProvider(appSettings), 
        ...
    });
如果只启用了
CredentialAuthProvider
,则需要首先在Swagger之外进行身份验证,例如手动调用URL:

/auth/credentials=Username=xxx&Password=xxx

如果成功,您可以使用Swagger用户界面访问经过身份验证的服务。

您能否提供更多详细信息:“……哪个Swagger不允许您这样做”?这不是基本身份验证的一种解决方法吗:
window.authorizations.add(“key”,new-ApiKeyAuthorization(“Authorization”,“basic”+key,“header”))
并以base64编码的用户名:密码的形式发送密钥?@ShP供参考,因为我认为这是一个很好的功能,所以我刚刚将其添加到最新的v4.0.43+版本中。太棒了!非常感谢。