我有一个没有问题的WebAPI.我已在本地测试并部署到我的服务器并在IIS中配置此服务以使用基本身份验证.我能够浏览我的服务,我收到了我期望的身份验证挑战,并且所有工作都在游泳!现在我想使用Fiddler来测试这个并且我已经构建了一个特定URL的POST,并且我收到了401(未授权)错误.所以我决定在我的Request Header中添加一个base64字符串,现在我收到500错误.
我想知道的是,我的请求标题看起来是否正确?我显然要混淆我的Host和base64字符串,其中包含Authentication challenge的格式username:password.
User-Agent: Fiddler
Host: xxx.xxx.xxx.xxx:xxxx
Content-Length: 185
Content-Type: text/json
Authorization: Basic jskadjfhlksadjhdflkjhiu9813ryiu34
Run Code Online (Sandbox Code Playgroud) 现在我正在使用ServiceStack及其身份验证和授权支持.
工作在CustomAuthenticationMvc(Web服务Host从应用程序)Use Cases项目,并试图了解该认证是如何工作的,我这样做:
public class AppHost : AppHostBase
{
public AppHost() : base("Basic Authentication Example",
typeof(AppHost).Assembly) { }
public override void Configure(Container container)
{
// register storage for user sessions
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<ISessionFactory>(c => new SessionFactory(
c.Resolve<ICacheClient>()));
//Register AuthFeature with custom user session and Basic auth provider
Plugins.Add(new AuthFeature(
() => new CustomUserSession(),
new AuthProvider[] { new BasicAuthProvider() }
) );
var userRep = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRep);
//Add a user …Run Code Online (Sandbox Code Playgroud) authentication authorization web-services basic-authentication servicestack