Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceStack basic authentication

Tags:

servicestack

I'm fairly new with ServiceStack authentication bit. First I configured basic authentication:

private void ConfigureAuth(Funq.Container container)
{
    var authFeature = new AuthFeature(() => new AuthUserSession(),
        new IAuthProvider[] { new BasicAuthProvider() }
    );
    authFeature.IncludeAssignRoleServices = false;

    // Default route: /auth/{provider}
    Plugins.Add(authFeature);

    container.Register<ICacheClient>(new MemoryCacheClient());
    container.Register<IUserAuthRepository>(GetAuthRepository());
}
  1. How to authenticate with a service request? for example:
    myweb/api/auth/basic?Userid=test@Password=234

  2. The authentication service endpoint in protected itself. calling myweb/api/auth/basic?Userid=test@Password=234 will redirect /Account/LogOn

I need a very simple authentication mechanism. Clients can simply authenticate by sending a JSON request.

like image 654
Amr Ellafy Avatar asked Aug 12 '26 13:08

Amr Ellafy


1 Answers

See ServiceStack AuthTests for examples on how to authenticate with Basic Auth.

like image 102
mythz Avatar answered Aug 17 '26 12:08

mythz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!