forked from Nfactor26/pixel-identity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Nfactor26#43 from Nfactor26/dummy-email-sender-and…
…-identityoptions-as-config IdentityOptions as configuration and EmailSender that writes to console and log
- Loading branch information
Showing
11 changed files
with
150 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,12 @@ IdentityHost=https://pixel.docker.localhost/pauth | |
#Plugin configuration | ||
Plugins__Collection__0__Type=EmailSender | ||
Plugins__Collection__0__Path=Plugins/Messenger | ||
Plugins__Collection__0__Name=Pixel.Identity.Messenger.Email | ||
Plugins__Collection__0__Name=Pixel.Identity.Messenger.Console | ||
Plugins__Collection__1__Type=DbStore | ||
Plugins__Collection__1__Path=Plugins/DbStore | ||
Plugins__Collection__1__Name=Pixel.Identity.Store.PostgreSQL | ||
|
||
#SMTP configuration for sending mails | ||
SMTP_Host=smtp.ethereal.email | ||
SMTP_Port=587 | ||
SMTP_UserName= | ||
SMTP_Password= | ||
SMTP_From=[email protected] | ||
IdentityOptions_SignIn_RequireConfirmedAccount=false | ||
|
||
ConnectionStrings__PostgreServerConnection=User ID=postgresadmin;Password=postgrespass;Server=postgres;Port=5432;Database=pixel_identity_db; | ||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Pixel.Identity.Core; | ||
using System.Text; | ||
|
||
namespace Pixel.Identity.Messenger.Console; | ||
|
||
/// <summary> | ||
/// <see cref="IEmailSender"/> implementation that prints the message as information | ||
/// on console and log and doesn't actually send the mail. | ||
/// </summary> | ||
public class EmailSender : IEmailSender | ||
{ | ||
private readonly ILogger<EmailSender> logger; | ||
|
||
public EmailSender(ILogger<EmailSender> logger) | ||
{ | ||
this.logger = logger; | ||
} | ||
|
||
public Task SendEmailAsync(string email, string subject, string htmlMessage) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.AppendLine($"----------------------------------------------------"); | ||
sb.AppendLine($"{email}:{subject}"); | ||
sb.AppendLine("message:[redacted]"); | ||
sb.AppendLine($"----------------------------------------------------"); | ||
this.logger.LogInformation(sb.ToString()); | ||
System.Console.WriteLine(sb.ToString()); | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Pixel.Identity.Core; | ||
using Pixel.Identity.Core.Plugins; | ||
|
||
namespace Pixel.Identity.Messenger.Console; | ||
|
||
public class EmailSenderPlugin : IServicePlugin | ||
{ | ||
public void ConfigureService(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddTransient<IEmailSender, EmailSender>(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Pixel.Identity.Messenger.Console/Pixel.Identity.Messenger.Console.csproj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Pixel.Identity.Core\Pixel.Identity.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,21 @@ | |
"Collection": [ | ||
{ | ||
"Type": "EmailSender", | ||
"Path": "Plugins/Messenger", | ||
"Name": "Pixel.Identity.Messenger.Email" | ||
"Path": "Plugins\\Messenger", | ||
"Name": "Pixel.Identity.Messenger.Console" | ||
}, | ||
{ | ||
"Type": "DbStore", | ||
"Path": "Plugins/DbStore", | ||
"Name": "Pixel.Identity.Store.PostgreSQL" | ||
"Path": "Plugins\\DbStore", | ||
"Name": "Pixel.Identity.Store.Mongo" | ||
} | ||
] | ||
}, | ||
"IdentityOptions": { | ||
"SignIn": { | ||
"RequireConfirmedAccount": false | ||
} | ||
}, | ||
"Identity": { | ||
"Certificates": { | ||
"EncryptionCertificatePath": "E:\\Git\\Pixel.Identity\\.certificates\\identity-encryption.pfx", | ||
|
@@ -28,13 +33,6 @@ | |
"SigningCertificateKey": "" | ||
} | ||
}, | ||
"SMTP": { | ||
"Host": "smtp.ethereal.email", | ||
"Port": 587, | ||
"UserName": "", | ||
"Password": "", | ||
"From": "[email protected]" | ||
}, | ||
"ConnectionStrings": { | ||
"SqlServerConnection": "Server=(localdb)\\mssqllocaldb;Database=pixel-identity-db;Trusted_Connection=True;MultipleActiveResultSets=true", | ||
"PostgreServerConnection": "User ID=postgresadmin;Password=postgrespass;Server=postgres;Port=5432;Database=pixel_identity_db;" | ||
|
This file contains 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
This file contains 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
This file contains 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