Created
May 1, 2012 06:11
-
-
Save e-tobi/2565534 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
DocumentStore = new EmbeddableDocumentStore | |
{ | |
Configuration = | |
{ | |
Catalog = { Catalogs = { new TypeCatalog(typeof(FixedPasswordAuthenticateClient)) } }, | |
AuthenticationMode = "oauth", | |
OAuthTokenCertificate = CertGenerator.GenerateNewCertificate("MyApp"), | |
OAuthTokenServer = "http://localhost:8080/OAuth/AccessToken", | |
}, | |
}; | |
... | |
public class FixedPasswordAuthenticateClient : IAuthenticateClient | |
{ | |
private string _passwordHash; | |
public FixedPasswordAuthenticateClient(string passwordHash) | |
{ | |
_passwordHash = passwordHash; | |
} | |
public bool Authenticate(DocumentDatabase documentDatabase, string username, string password, | |
out AccessTokenBody.DatabaseAccess[] allowedDatabases) | |
{ | |
allowedDatabases = new[] | |
{ | |
new AccessTokenBody.DatabaseAccess | |
{ | |
TenantId = "*" | |
}, | |
}; | |
if (!String.IsNullOrEmpty(password)) | |
{ | |
using (var sha = SHA256.Create()) | |
{ | |
return PasswordHash == Convert.ToBase64String(sha.ComputeHash(Encoding.Unicode.GetBytes(password))); | |
} | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment