Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created August 16, 2018 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpoDesign/26482f97e2dc8e35625bcd7b08cafb54 to your computer and use it in GitHub Desktop.
Save cpoDesign/26482f97e2dc8e35625bcd7b08cafb54 to your computer and use it in GitHub Desktop.
How to get client list with all auth. keys to be served to a list of services. using token for authentication. This presents how-ever security risk as all active configuration is presented at once.
/// <summary>
/// used to provide definition for gateway service about active keys for clients, to about active client configuration
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet]
public IActionResult GetClientList(string token)
{
if (ValidateToken(token))
{
var clientKey = Guid.NewGuid();
var clientAccessKey = Guid.NewGuid();
var clientAccessKey1 = Guid.NewGuid();
var clientAccessKey2 = Guid.NewGuid();
var activeClientList = new
{
clientKey = new
{
clientAccessKey = DateTime.UtcNow.AddYears(1),
clientAccessKey1 = DateTime.UtcNow.AddDays(90)
}
};
var model = new
{
activeClientList,
updateUrl = "https://mydomain.com/urlPath",
refreshRate = 90,
};
// log message before sending to audit
return Ok(model);
}
else
{
// someone can be trying to hack us, lets log everything
return Ok();
}
}
/// <summary>
/// sed to validate
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
private bool ValidateToken(string token)
{
///todo
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment