Özel bir yetkilendirme yanıtı vermek mümkün mü? Zaten CredentialsAuthProvider'dan devraldığım kendi özel kimlik doğrulama sağlayıcım var.Özel kimlik doğrulama nesnesini ServiceStack kimlik doğrulamasından döndürme
İstemci onların sunucu oturumu sona erecek zaman tam olarak bilir ki, yanıt olarak oturum son kullanma tarihi dönmek istiyorum:
public override object Authenticate(IServiceBase authService, IAuthSession session, Auth request)
{
// get base response
var response = base.Authenticate(authService, session, request);
// grab the session
var customSession = authService.GetSession() as CustomUserSession;
// if response can be cast and customSession exists
if (response is AuthResponse && customSession != null)
{
// cast
var authResponse = response as AuthResponse;
// build custom response
var customAuthResponse = new CustomAuthResponse
{
ReferrerUrl = authResponse.ReferrerUrl,
SessionExpiry = customSession.SessionExpires,
SessionId = authResponse.SessionId,
ResponseStatus = authResponse.ResponseStatus,
UserName = authResponse.UserName
};
return customAuthResponse;
}
// return the standard response
return response;
}
:
{
"sessionId": "bG27SdxbRkqJqU6xv/gvBw==",
"userName": "[email protected]",
"sessionExpires": "2013-04-29T03:27:14.0000000",
"responseStatus": {}
}
ben şöyle kimlik doğrulaması yöntemi geçersiz kılabilirsiniz
Bu, oturumun zaten aktif olduğu durum dışında iyi çalışır.
var alreadyAuthenticated = response == null;
response = response ?? new AuthResponse {
UserName = session.UserAuthName,
SessionId = session.Id,
ReferrerUrl = referrerUrl,
};
aşağıda Paaschpa fikirlerini takip ederek, aşağıdaki kuvvetleri yeniden auth hep yeniden doğrulanmış olması: Bu durumda, bunu geçersiz kılmak için belirgin bir yol AuthService Mesaj yöntemi geçerli bir oturum ve automatically returns a standard AuthResponse denetler ve orada
public override bool IsAuthorized(IAuthSession session, IOAuthTokens tokens, Auth request = null)
{
// force re-authentication. Not great, but no other obvious way to do this
if (request != null)
{
return false; // auth or re-auth calls
}
return base.IsAuthorized(session, tokens, request);
}
herkes bunun için iyi bir yol düşünebiliyor
: riskler açık birden aktif oturumları bırakarak orada katılabilecek gibi ama öyle görünüyor? Kendi Kimlik Doğrulama Hizmeti'ni uygulayabilirim, ancak AuthFeature'ı nasıl geçersiz kılacağımı bilmiyorum?
CredentialsAuthProvider ait
Alt Sınıf mu bu yardımı gibi bir şey? https://github.com/ServiceStack/ServiceStack/wiki/Sessions#using-typed-sessions-in-servicestack – paaschpa
@paaschpa ne yazık ki değil. Bu özel oturum değeri sunucuda tutulan bir şeydir. Özel bir yetkilendirme yanıtı sunmak istiyorum. Daha fazla bir şey varsa: http://stackoverflow.com/questions/13855996/how-to-change-http-401-response-in-servicestack, ancak başarısız olanlardan ziyade başarılı bir giriş için. – Junto