IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Commit 4f9f6340 authored by Douglas Williams's avatar Douglas Williams
Browse files

Release 3 work to date

parent 88a41a80
using Microsoft.EntityFrameworkCore.Migrations;
using System;
namespace OpenCredentialPublisher.Data.Contexts.Migrations
{
public partial class FixShares_CreatedAtType : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedAt",
table: "Shares",
type: "datetime2",
nullable: false,
oldClrType: typeof(DateTimeOffset),
oldType: "datetimeoffset");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "CreatedAt",
table: "Shares",
type: "datetimeoffset",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime2");
}
}
}
......@@ -2,6 +2,21 @@ namespace OpenCredentialPublisher.Data.Models.Enums
{
public enum CredentialRequestStepEnum
{
Initiated = 0, PendingAgent = 1, PendingSchema = 2, PendingCredentialDefinition = 3, ReadyToSend = 4, SendingOffer = 5, OfferSent = 6, OfferAccepted = 7, CheckingRevocationStatus = 8, CredentialIsRevoked = 9, CredentialIsStillValid = 10, Error = 13, ErrorWritingSchema = 14, ErrorWritingCredentialDefinition = 15
Initiated = 0,
PendingAgent = 1,
PendingSchema = 2,
PendingCredentialDefinition = 3,
ReadyToSend = 4,
SendingOffer = 5,
OfferSent = 6,
OfferAccepted = 7,
CheckingRevocationStatus = 8,
CredentialIsRevoked = 9,
CredentialIsStillValid = 10,
PendingSchemaEndorsement = 11,
PendingCredentialDefinitionEndorsement = 12,
Error = 13,
ErrorWritingSchema = 14,
ErrorWritingCredentialDefinition = 15
}
}
......@@ -19,6 +19,7 @@ namespace OpenCredentialPublisher.Data.Models.Enums
ReadyForVerification = 15,
Verified = 16,
Unused = 17,
Success = 18
Success = 18,
NeedsEndorsement = 19
}
}
......@@ -7,6 +7,7 @@ namespace OpenCredentialPublisher.Data.Options
public class AzureBlobOptions
{
public const string Section = "AzureBlob";
public bool StoreCredentialJson { get; set; } = false;
public string StorageConnectionString { get; set; }
}
......
......@@ -7,16 +7,18 @@ namespace OpenCredentialPublisher.Data.Options
public class SiteSettingsOptions
{
public const string Section = "SiteSettings";
public string AdminEmailAddress { get; set; }
public bool ShowFooter { get; set; }
public string ContactUsUrl { get; set; }
public string PrivacyPolicyUrl { get; set; }
public string TermsOfUseUrl { get; set; }
public string TermsOfServiceUrl { get; set; }
public bool EnableSource { get; set; }
public bool EnableCollections { get; set; }
public int SessionTimeout { get; set; }
public string SiteName { get; set; }
public int AccessTokenLifetime { get; set; }
public bool SlidingSessionExpiration { get; set; }
public string TestPortalName { get; set; }
......
using OpenCredentialPublisher.Data.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenCredentialPublisher.Data.ViewModels.nG
{
public class FooterSettingsVM
{
public bool ShowFooter { get; set; }
public string ContactUsUrl { get; set; }
public string PrivacyPolicyUrl { get; set; }
public string TermsOfServiceUrl { get; set; }
}
}
\ No newline at end of file
declare module server {
interface footerSettingsVM {
showFooter: boolean;
contactUsUrl: string;
privacyPolicyUrl: string;
termsOfServiceUrl: string;
}
}
......@@ -22,6 +22,10 @@ namespace OpenCredentialPublisher.Data.Xsds
{
}
namespace OpenCredentialPublisher.Data.Xsds
{
}
//
// This source code was auto-generated by xsd, Version=4.6.1055.0.
//
......
......@@ -22,6 +22,10 @@ namespace OpenCredentialPublisher.Data.Xsds
{
}
namespace OpenCredentialPublisher.Data.Xsds
{
}
//
// This source code was auto-generated by xsd, Version=4.6.1055.0.
//
......
......@@ -46,7 +46,15 @@ namespace OpenCredentialPublisher.Services.Constants
public const string UpdateEndpointsResponse = "did:sov:123456789abcdefghi1234;spec/configs/0.6/COM_METHOD_UPDATED";
public const string WriteCredentialDefinitionProblem = "did:sov:123456789abcdefghi1234;spec/write-cred-def/0.6/problem-report";
public const string WriteCredentialDefinitionResponse = "did:sov:123456789abcdefghi1234;spec/write-cred-def/0.6/status-report";
public const string WriteCredentialDefintionNeedEndorsement = "did:sov:123456789abcdefghi1234;spec/write-cred-def/0.6/needs-endorsement";
public const string WriteSchemaProblem = "did:sov:123456789abcdefghi1234;spec/write-schema/0.6/problem-report";
public const string WriteSchemaResponse = "did:sov:123456789abcdefghi1234;spec/write-schema/0.6/status-report";
public const string WriteSchemaNeedEndorsement = "did:sov:123456789abcdefghi1234;spec/write-schema/0.6/needs-endorsement";
}
public static class AdminMessageFamilies
{
public const string UpdateCredentialDefinitionMessage = "randa:admin:spec/cred-def/1.0/update";
public const string UpdateCredentialSchemaMessage = "randa:admin:spec/cred-schema/1.0/update";
}
}
......@@ -55,7 +55,7 @@ namespace OpenCredentialPublisher.Services.Implementations
Name = name,
Tag = tag,
ThreadId = Guid.NewGuid().ToString().ToLower(),
CreatedOn = DateTimeOffset.UtcNow,
CreatedAt = DateTime.UtcNow,
StatusId = StatusEnum.Pending
};
......@@ -65,12 +65,12 @@ namespace OpenCredentialPublisher.Services.Implementations
return await _walletContext.CredentialDefinitions.AsNoTracking().FirstOrDefaultAsync(cd => cd.CredentialSchemaId == credentialSchemaId && cd.Tag == tag);
}
public async Task<CredentialDefinition> UpdateCredentialDefinitionAsync(string threadId, string credentialDefinitionId)
public async Task<CredentialDefinition> UpdateCredentialDefinitionAsync(string threadId, string credentialDefinitionId, StatusEnum statusId = StatusEnum.Created)
{
var definition = await GetCredentialDefinitionAsync(threadId);
definition.CredentialDefinitionId = credentialDefinitionId;
definition.StatusId = StatusEnum.Created;
definition.ModifiedOn = DateTimeOffset.UtcNow;
definition.StatusId = statusId;
definition.ModifiedAt = DateTime.UtcNow;
_walletContext.Update(definition);
await _walletContext.SaveChangesAsync();
_walletContext.Entry(definition).State = EntityState.Detached;
......@@ -79,7 +79,7 @@ namespace OpenCredentialPublisher.Services.Implementations
public async Task<CredentialDefinition> UpdateCredentialDefinitionAsync(CredentialDefinition definition)
{
definition.ModifiedOn = DateTimeOffset.UtcNow;
definition.ModifiedAt = DateTime.UtcNow;
_walletContext.Update(definition);
await _walletContext.SaveChangesAsync();
_walletContext.Entry(definition).State = EntityState.Detached;
......@@ -93,7 +93,7 @@ namespace OpenCredentialPublisher.Services.Implementations
{
credentialRequest.ErrorMessage = "There was a problem writing the definition for your credential to the chain. Please try again later.";
credentialRequest.CredentialRequestStep = CredentialRequestStepEnum.ErrorWritingCredentialDefinition;
credentialRequest.ModifiedOn = DateTime.UtcNow;
credentialRequest.ModifiedAt = DateTime.UtcNow;
await _queueService.SendMessageAsync(
CredentialStatusNotification.QueueName,
......
......@@ -80,7 +80,7 @@ namespace OpenCredentialPublisher.Services.Implementations
Attributes = jsonAttributes,
ThreadId = Guid.NewGuid().ToString().ToLower(),
StatusId = StatusEnum.Pending,
CreatedOn = DateTimeOffset.UtcNow
CreatedAt = DateTime.UtcNow
};
await _walletContext.CredentialSchemas.AddAsync(credentialSchema);
......@@ -89,12 +89,12 @@ namespace OpenCredentialPublisher.Services.Implementations
return await GetCredentialSchemaAsync(name, schemaHash);
}
public async Task<CredentialSchema> UpdateCredentialSchemaAsync(string threadId, string schemaId)
public async Task<CredentialSchema> UpdateCredentialSchemaAsync(string threadId, string schemaId, StatusEnum statusId = StatusEnum.Created)
{
var schema = await GetCredentialSchemaAsync(threadId);
schema.SchemaId = schemaId;
schema.StatusId = StatusEnum.Created;
schema.ModifiedOn = DateTimeOffset.UtcNow;
schema.StatusId = statusId;
schema.ModifiedAt = DateTime.UtcNow;
_walletContext.Update(schema);
await _walletContext.SaveChangesAsync();
_walletContext.Entry(schema).State = EntityState.Detached;
......@@ -103,7 +103,7 @@ namespace OpenCredentialPublisher.Services.Implementations
public async Task<CredentialSchema> UpdateCredentialSchemaAsync(CredentialSchema credentialSchema)
{
credentialSchema.ModifiedOn = DateTimeOffset.UtcNow;
credentialSchema.ModifiedAt = DateTime.UtcNow;
_walletContext.Update(credentialSchema);
await _walletContext.SaveChangesAsync();
_walletContext.Entry(credentialSchema).State = EntityState.Detached;
......@@ -117,7 +117,7 @@ namespace OpenCredentialPublisher.Services.Implementations
{
credentialRequest.ErrorMessage = "There was a problem writing the schema for your credential to the chain. Please try again later.";
credentialRequest.CredentialRequestStep = CredentialRequestStepEnum.ErrorWritingSchema;
credentialRequest.ModifiedOn = DateTime.UtcNow;
credentialRequest.ModifiedAt = DateTime.UtcNow;
await _queueService.SendMessageAsync(
CredentialStatusNotification.QueueName,
......
......@@ -46,6 +46,8 @@ namespace OpenCredentialPublisher.Services.Implementations
ConnectionStatusNotification.MessageType => eventGridEvent.Data.ToObjectFromJson<ConnectionStatusNotification>(),
CredentialStatusNotification.MessageType => eventGridEvent.Data.ToObjectFromJson<CredentialStatusNotification>(),
RequestProofInvitationNotification.MessageType => eventGridEvent.Data.ToObjectFromJson<RequestProofInvitationNotification>(),
CredentialDefinitionNeedsEndorsementNotification.MessageType => eventGridEvent.Data.ToObjectFromJson<CredentialDefinitionNeedsEndorsementNotification>(),
SchemaNeedsEndorsementNotification.MessageType => eventGridEvent.Data.ToObjectFromJson<SchemaNeedsEndorsementNotification>(),
_ => throw new NotImplementedException(eventGridEvent.EventType)
};
await HandlerAsync(notification);
......@@ -67,6 +69,8 @@ namespace OpenCredentialPublisher.Services.Implementations
ConnectionStatusNotification.MessageType => JsonSerializer.Deserialize<ConnectionStatusNotification>(message, options),
CredentialStatusNotification.MessageType => JsonSerializer.Deserialize<CredentialStatusNotification>(message, options),
RequestProofInvitationNotification.MessageType => JsonSerializer.Deserialize<RequestProofInvitationNotification>(message, options),
CredentialDefinitionNeedsEndorsementNotification.MessageType => JsonSerializer.Deserialize<CredentialDefinitionNeedsEndorsementNotification>(message, options),
SchemaNeedsEndorsementNotification.MessageType => JsonSerializer.Deserialize<SchemaNeedsEndorsementNotification>(message, options),
_ => throw new NotImplementedException(messageType)
};
await HandlerAsync(notification);
......@@ -132,7 +136,7 @@ namespace OpenCredentialPublisher.Services.Implementations
Subject = $"Response Received to Proof Request - {proof.Name} ({proof.PublicId})",
SendAttempts = 0,
StatusId = StatusEnum.Created,
CreatedOn = DateTimeOffset.UtcNow,
CreatedAt = DateTime.UtcNow,
ProofRequestId = proof.Id
};
await emailHelperService.AddMessageAsync(proofMessage);
......@@ -147,5 +151,63 @@ namespace OpenCredentialPublisher.Services.Implementations
_logger.LogError(ex, ex.Message, notification);
}
}
private async Task HandlerAsync(CredentialDefinitionNeedsEndorsementNotification notification)
{
try
{
using var scope = _scopeFactory.CreateScope();
var emailHelperService = scope.ServiceProvider.GetRequiredService<EmailHelperService>();
var defMessage = new MessageModel
{
Body = new StringBuilder($"A credential definition requires endorsement by Evernym. Please send the following values to support@evernym.com<br />")
.Append($"IssuerDID: {notification.IssuerDid}<br />")
.Append($"Verkey: {notification.IssuerVerkey}<br />")
.Append($"CredDefId: {notification.CredentialDefinitionId}<br />")
.Append($"CredDefJson: {notification.CredDefJson}<br />")
.Append($"ThreadId: {notification.ThreadId}<br />").ToString(),
Recipient = _siteSettings.AdminEmailAddress,
Subject = $"Credential Definition Endorsement Required",
SendAttempts = 0,
StatusId = StatusEnum.Created,
CreatedAt = DateTime.UtcNow
};
await emailHelperService.AddMessageAsync(defMessage);
await _emailService.SendEmailAsync(defMessage.Recipient, defMessage.Subject, defMessage.Body, true);
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message, notification);
}
}
private async Task HandlerAsync(SchemaNeedsEndorsementNotification notification)
{
try
{
using var scope = _scopeFactory.CreateScope();
var emailHelperService = scope.ServiceProvider.GetRequiredService<EmailHelperService>();
var schemaMessage = new MessageModel
{
Body = new StringBuilder($"A schema requires endorsement by Evernym. Please send the following values to support@evernym.com<br />")
.Append($"IssuerDID: {notification.IssuerDid}<br />")
.Append($"Verkey: {notification.IssuerVerkey}<br />")
.Append($"SchemaId: {notification.SchemaId}<br />")
.Append($"SchemaJson: {notification.SchemaJson}<br />")
.Append($"ThreadId: {notification.ThreadId}<br />").ToString(),
Recipient = _siteSettings.AdminEmailAddress,
Subject = $"Schema Endorsement Required",
SendAttempts = 0,
StatusId = StatusEnum.Created,
CreatedAt = DateTime.UtcNow
};
await emailHelperService.AddMessageAsync(schemaMessage);
await _emailService.SendEmailAsync(schemaMessage.Recipient, schemaMessage.Subject, schemaMessage.Body, true);
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message, notification);
}
}
}
}
......@@ -122,10 +122,21 @@ namespace OpenCredentialPublisher.Services.Implementations
}
return clrLinkVMs;
}
private string GetLinkUrl(HttpRequest request, string id)
public static string GetLinkUrl(HttpRequest request, string id)
{
//var Request = model.Request;
if (Uri.TryCreate($"{request.Scheme}://{request.Host}{request.PathBase}/Public/Links/Display/{id}", UriKind.Absolute, out var url))
if (Uri.TryCreate($"{request.Scheme}://{request.Host}{request.PathBase}/s/{id}", UriKind.Absolute, out var url))
{
return url.AbsoluteUri;
}
return string.Empty;
}
public static string GetLinkUrl(Uri baseUri, string id)
{
//var Request = model.Request;
if (Uri.TryCreate($"{baseUri.Scheme}://{baseUri.Authority}/s/{id}", UriKind.Absolute, out var url))
{
return url.AbsoluteUri;
}
......@@ -212,10 +223,10 @@ namespace OpenCredentialPublisher.Services.Implementations
var item = await _context.Links
.Include(l => l.Shares)
.ThenInclude(s => s.Messages)
.AsNoTracking()
.SingleAsync(x => x.Id == id);
_context.Links.Remove(item);
item.Delete();
//_context.Links.Remove(item);
await _context.SaveChangesAsync();
}
......
using MediatR;
using OpenCredentialPublisher.Shared.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace OpenCredentialPublisher.Shared.Commands
{
public class CredentialDefinitionNeedsEndorsementNotification : INotification, ICommand
{
public const string FunctionName = "NotifyAdminCredDefFunction";
public const string QueueName = "notifyadmincreddefqueue";
public const string MessageType = "cred-def-needs-endorsement";
[JsonPropertyName("issuerDid")]
public string IssuerDid { get; set; }
[JsonPropertyName("issuerVerkey")]
public string IssuerVerkey { get; set; }
[JsonPropertyName("threadId")]
public string ThreadId { get; set; }
[JsonPropertyName("CredentialDefinitionId")]
public string CredentialDefinitionId { get; set; }
[JsonPropertyName("credDefJson")]
public string CredDefJson { get; set; }
public CredentialDefinitionNeedsEndorsementNotification()
{
}
public CredentialDefinitionNeedsEndorsementNotification(string issuerDid, string issuerVerkey, string threadId, string credentialDefinitionId, string credDefJson)
{
IssuerDid = issuerDid;
IssuerVerkey = issuerVerkey;
ThreadId = threadId;
CredentialDefinitionId = credentialDefinitionId;
CredDefJson = credDefJson;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment