. CredentialsAuthProvider
, , (.. , MemoryCacheClient). - , , cookie , , Service Client, . ServiceStack, cookie , .
ServiceStack , Cookie - :
public object Any(ClientRequest request)
{
var session = base.SessionAs<AuthUserSession>();
var client = new JsonServiceClient("http://localhost:8088");
client.SetSessionId(session.Id);
var response = client.Post(new Hello {
Name = "user of server Y"
});
return new TwoPhaseResponse { Result = $"Server X says: {response.Result}" };
}
BasicAuthProvider
, HTTP Basic Auth BasicAuthProvider
, UserName/Password , :
var basicAuth = base.Request.GetBasicAuthUserAndPassword();
client.UserName = basicAuth.Value.Key;
client.Password = basicAuth.Value.Value;
client.AlwaysSendBasicAuthHeader = true;
/, , . , ServiceStack BasicAuthProvider
User Auth Repository, /.
API
API- AuthProvider, - , UserName/Password API
var apikey = base.Request.GetApiKey();
client.BearerToken = apikey.Id;
, Same ApiKeyAuthProvider
User Auth Repository, API.
JWT AuthProvider
, , (, Caching Provider/User Auth Repository), JWT Auth Provider, , ServiceStack, JWT, ServiceStack, JwtAuthProviderReader.
JWT, :
var bearerToken = base.Request.GetBearerToken()
?? base.Request.GetCookieValue(Keywords.TokenCookie);
client.BearerToken = bearerToken;