API가 ServiceStack으로 작성되었으며 클라이언트 인증을 위해 빌드를 시도하고 있습니다. 현재이 API는 Android 클라이언트 (Xamarin/C#)에서만 액세스 할 수 있습니다. API 자체는 Apache/mod_mono를 사용하는 데비안 서버에서 실행 중입니다Servicestack 사용자 세션이 작동하지 않습니다.
Github에서 읽고 난 후에도 클라이언트가 유효한 자격 증명을 제공하면 (테스트의 경우 기본 HTTP 인증) 사용자는 세션을 가져오고 동일한 세션의 후속 요청에서 자격 증명이 다시 확인되지 않습니다.
AppHost 등급 :
{
public class AppHost
: AppHostBase
{
public AppHost() //Tell ServiceStack the name and where to find your web services
: base("Service Call Service", typeof(ServiceCallsService).Assembly) { }
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
// Session storage
container.Register<ICacheClient>(new MemoryCacheClient());
// auth feature and session feature
Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new[] { new userAuth() }
) { HtmlRedirect = null });
}
public class userAuth : BasicAuthProvider
{
public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
{
peruseAuth peruseAuthHandler= new peruseAuth();
errorLogging MyErrorHandler = new errorLogging() ;
if (peruseAuthHandler.ValidateUser(authService, userName, password))
{
try
{
var session = (AuthUserSession)authService.GetSession(false);
session.UserAuthId = userName;
session.IsAuthenticated = true;
return true;
}
catch(Exception ex)
{
MyErrorHandler.LogError(ex, this) ;
return false ;
}
}
else
{
Console.Write("False");
return false;
}
}
}
JsonServiceClient :(그냥 "로그인"이벤트)
btnLogin.Click += (sender, e) =>
{
// Set credentials from EditText elements in Main.axml
client.SetCredentials(txtUser.Text, txtPass.Text);
// Force the JsonServiceClient to always use the auth header
client.AlwaysSendBasicAuthHeader = true;
};
내가 로깅을 조금 해 봤는데
하고, 클라이언트가 작업을 수행 할 때마다 데이터베이스에 대해 사용자 이름/암호가 확인되고있는 것으로 보입니다. 뭔가 잘못 되었나요? 아니면 예상 된 결과입니까?