This commit is contained in:
2020-06-23 18:20:51 +00:00
parent 854f1c153a
commit 12fbe66bd9
6 changed files with 20 additions and 20 deletions

2
.vscode/launch.json vendored
View File

@@ -45,7 +45,7 @@
//"AYANOVA_LOG_LEVEL": "Debug",
"AYANOVA_DEFAULT_TRANSLATION": "en",
//TRANSLATION MUST BE en for Integration TESTING
//"AYANOVA_PERMANENTLY_ERASE_DATABASE": "true",
"AYANOVA_PERMANENTLY_ERASE_DATABASE": "true",
"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;",
"AYANOVA_USE_URLS": "http://*:7575;",
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",

View File

@@ -7,6 +7,6 @@ namespace AyaNova.Models
{
public long Id { get; set; }
public string Key { get; set; }
public Guid DbId { get; set; }
public string DbId { get; set; }
}
}

View File

@@ -11,11 +11,9 @@ namespace AyaNova.Models
{
[Required]
[Key]
public Guid Id { get; set; }
public string Id { get; set; }
public int Schema { get; set; }
//ef core requires this
public SchemaVersion() { }

View File

@@ -7,10 +7,10 @@ namespace AyaNova.Models
{
public RequestTrial()
{
DbId = Guid.Empty;//default this because it's coming from the client without a dbid as the server will set it before forwarding it on
DbId = string.Empty;//default this because it's coming from the client without a dbid as the server will set it before forwarding it on
}
[Required]
public Guid DbId { get; set; }
public string DbId { get; set; }
[Required, EmailAddress]
public string Email { get; set; }
[Required]

View File

@@ -173,10 +173,10 @@ namespace AyaNova.Util
using (var cm = ct.Database.GetDbConnection().CreateCommand())
{
await ct.Database.OpenConnectionAsync();
cm.CommandText = "CREATE TABLE aschemaversion (schema INTEGER NOT NULL, id uuid not null);";
cm.CommandText = "CREATE TABLE aschemaversion (schema INTEGER NOT NULL, id text not null);";
await cm.ExecuteNonQueryAsync();
cm.CommandText = $"insert into aschemaversion (schema, id) values (1,'{Guid.NewGuid()}');";
cm.CommandText = $"insert into aschemaversion (schema, id) values (1,'{AyaNova.Util.Hasher.GenerateSalt()}');";
await cm.ExecuteNonQueryAsync();
await ct.Database.CloseConnectionAsync();
@@ -351,7 +351,7 @@ $BODY$;
LogUpdateMessage(log);
//Add user table
await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid uuid, key text not null)");
await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid text, key text not null)");
await SetSchemaLevelAsync(++currentSchema);
}

View File

@@ -66,7 +66,7 @@ namespace AyaNova.Core
private static AyaNovaLicenseKey _ActiveLicense = new AyaNovaLicenseKey();
//The license dbid, separate from teh server dbid
private static Guid LicenseDbId { get; set; }
private static string LicenseDbId { get; set; }
#region license classes
@@ -246,7 +246,7 @@ namespace AyaNova.Core
public string LicenseFormat { get; set; }
public string Id { get; set; }
public string RegisteredTo { get; set; }
public Guid DbId { get; set; }
public string DbId { get; set; }
public DateTime LicenseExpiration { get; set; }
public DateTime MaintenanceExpiration { get; set; }
public List<LicenseFeature> Features { get; set; }
@@ -295,7 +295,7 @@ namespace AyaNova.Core
#region Exposed properties
//The database id value stored in the schema table
internal static Guid ServerDbId { get; private set; }
internal static string ServerDbId { get; private set; }
/// <summary>
/// Fetch a summary of the license key for displaying to the end user
@@ -452,7 +452,7 @@ namespace AyaNova.Core
{
trialRequest.DbId = ServerDbId;
log.LogDebug($"Requesting trial license for DBID {LicenseDbId.ToString()}");
log.LogDebug($"Requesting trial license for DBID {LicenseDbId}");
string sUrl = $"{LICENSE_SERVER_URL}rvr";
try
{
@@ -489,11 +489,11 @@ namespace AyaNova.Core
internal static async Task<string> FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob)
{
if (calledFromInternalJob)
log.LogTrace($"Fetching license for DBID {LicenseDbId.ToString()} (called by job)");
log.LogTrace($"Fetching license for DBID {LicenseDbId} (called by job)");
else
log.LogInformation($"Fetching license for DBID {LicenseDbId.ToString()}");
log.LogInformation($"Fetching license for DBID {LicenseDbId}");
string sUrl = $"{LICENSE_SERVER_URL}rvf/{LicenseDbId.ToString()}";
string sUrl = $"{LICENSE_SERVER_URL}rvf/{LicenseDbId}";
try
{
// string ResponseText = await ServiceProviderProvider.HttpClientFactory.CreateClient().GetStringAsync(sUrl);
@@ -579,7 +579,8 @@ namespace AyaNova.Core
{
//First fetch the schema db id for the servers database, the license must match
var schema = await ct.SchemaVersion.AsNoTracking().SingleOrDefaultAsync();
if (schema == null || schema.Id == Guid.Empty)
//if (schema == null || schema.Id == Guid.Empty)
if (schema == null || string.IsNullOrWhiteSpace(schema.Id) )
{
//cryptic message deliberately, this is probably caused by someone trying to circumvent licensing
var msg = "E1030 - Database integrity check failed (2). Contact support.";
@@ -603,7 +604,8 @@ namespace AyaNova.Core
}
//ensure DB ID
if (ldb.DbId == Guid.Empty)
// if (ldb.DbId == Guid.Empty)
if (string.IsNullOrWhiteSpace(ldb.DbId ))
{
ldb.DbId = ServerDbId;
//Convert the no tracking record fetched above to tracking
@@ -803,7 +805,7 @@ EQIDAQAB
throw new ApplicationException($"E1020 - License.Parse -> License key format {key.LicenseFormat} not recognized");
key.Id = (string)token.SelectToken("Key.Id");
key.RegisteredTo = (string)token.SelectToken("Key.RegisteredTo");
key.DbId = (Guid)token.SelectToken("Key.DBID");
key.DbId = (string)token.SelectToken("Key.DBID");
if (key.DbId != ServerDbId)
throw new ApplicationException($"E1020 - License.Parse -> License key does not match this server");
key.LicenseExpiration = (DateTime)token.SelectToken("Key.LicenseExpiration");