Security pattern indicates that web services required authorization when accessing.
<Pattern name="Security">
</Pattern>
Actually, there are no parameters.
GL generates a partial class CustomCredentialsAuthProvider in source file DomainServicesHost.cs. You should implement only 2 methods for using security.
public partial class CustomCredentialsAuthProvider : CredentialsAuthProvider
{
public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
{
//Add here your custom auth logic (database calls etc)
bool userAuthentified = ...
return userAuthentified; //
}
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo)
{
//Important: You need to save the session
authService.SaveSession(session, SessionExpiry);
}
}
WebClientFactory.AuthProviderName = CredentialsAuthProvider.Name;
WebClientFactory.UserName = "john"; // User name should have 3 or more characters
WebClientFactory.Password = "password";
WebClientFactory.RemeberMe = true;
Currency currency = Currency.GetByCode("EUR");
Assert.IsNotNull(currency, "Authetification failed");