Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
吴兆宣
IdentityServer4-Admin
Commits
5f641640
Commit
5f641640
authored
6 years ago
by
Michał Drzał
Browse files
Options
Download
Email Patches
Plain Diff
Added plumbing
parent
00458fcc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
50 deletions
+80
-50
src/Skoruba.IdentityServer4.STS.Identity/Configuration/Constants/ConfigurationConsts.cs
...S.Identity/Configuration/Constants/ConfigurationConsts.cs
+2
-1
src/Skoruba.IdentityServer4.STS.Identity/Configuration/SmtpConfiguration.cs
...tyServer4.STS.Identity/Configuration/SmtpConfiguration.cs
+1
-1
src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs
...ba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs
+24
-1
src/Skoruba.IdentityServer4.STS.Identity/Services/SendgridEmailSender.cs
...ntityServer4.STS.Identity/Services/SendgridEmailSender.cs
+3
-3
src/Skoruba.IdentityServer4.STS.Identity/Startup.cs
src/Skoruba.IdentityServer4.STS.Identity/Startup.cs
+1
-0
src/Skoruba.IdentityServer4.STS.Identity/appsettings.json
src/Skoruba.IdentityServer4.STS.Identity/appsettings.json
+49
-44
No files found.
src/Skoruba.IdentityServer4.STS.Identity/Configuration/Constants/ConfigurationConsts.cs
View file @
5f641640
...
...
@@ -3,7 +3,8 @@
public
class
ConfigurationConsts
{
public
const
string
AdminConnectionStringKey
=
"AdminConnection"
;
public
const
string
SendgridConnectionStringKey
=
"Sendgrid"
;
public
const
string
ResourcesPath
=
"Resources"
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Skoruba.IdentityServer4.STS.Identity/Configuration/SmtpConfiguration.cs
View file @
5f641640
...
...
@@ -10,7 +10,7 @@ namespace Skoruba.IdentityServer4.STS.Identity.Configuration
public
string
Host
{
get
;
set
;
}
public
string
Login
{
get
;
set
;
}
public
string
Password
{
get
;
set
;
}
public
int
Port
{
get
;
set
;
}
=
587
;
public
int
Port
{
get
;
set
;
}
=
587
;
// default smtp port
public
bool
UseSSL
{
get
;
set
;
}
=
true
;
}
}
This diff is collapsed.
Click to expand it.
src/Skoruba.IdentityServer4.STS.Identity/Helpers/StartupHelpers.cs
View file @
5f641640
...
...
@@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
SendGrid
;
using
Serilog
;
using
Skoruba.IdentityServer4.STS.Identity.Configuration
;
using
Skoruba.IdentityServer4.STS.Identity.Configuration.Constants
;
...
...
@@ -62,6 +63,29 @@ namespace Skoruba.IdentityServer4.STS.Identity.Helpers
app
.
UseReferrerPolicy
(
options
=>
options
.
NoReferrer
());
}
public
static
void
AddEmailSenders
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
var
sendgridConnectionString
=
configuration
.
GetConnectionString
(
ConfigurationConsts
.
SendgridConnectionStringKey
);
var
smtpConfiguration
=
configuration
.
GetSection
(
nameof
(
SmtpConfiguration
)).
Get
<
SmtpConfiguration
>();
var
sendgridConfiguration
=
configuration
.
GetSection
(
nameof
(
SendgridConfiguration
)).
Get
<
SendgridConfiguration
>();
if
(!
string
.
IsNullOrWhiteSpace
(
sendgridConnectionString
))
{
services
.
AddSingleton
<
ISendGridClient
>(
_
=>
new
SendGridClient
(
sendgridConnectionString
));
services
.
AddSingleton
(
sendgridConfiguration
);
services
.
AddTransient
<
IEmailSender
,
SendgridEmailSender
>();
}
else
if
(
smtpConfiguration
!=
null
)
{
services
.
AddSingleton
(
smtpConfiguration
);
services
.
AddTransient
<
IEmailSender
,
SmtpEmailSender
>();
}
else
{
services
.
AddSingleton
<
IEmailSender
,
EmailSender
>();
}
}
public
static
void
AddAuthenticationServices
<
TContext
,
TUserIdentity
,
TUserIdentityRole
>(
this
IServiceCollection
services
,
IHostingEnvironment
hostingEnvironment
,
IConfiguration
configuration
,
ILogger
logger
)
where
TContext
:
DbContext
where
TUserIdentity
:
class
where
TUserIdentityRole
:
class
{
...
...
@@ -73,7 +97,6 @@ namespace Skoruba.IdentityServer4.STS.Identity.Helpers
.
AddEntityFrameworkStores
<
TContext
>()
.
AddDefaultTokenProviders
();
services
.
AddSingleton
<
IEmailSender
,
EmailSender
>();
services
.
Configure
<
IISOptions
>(
iis
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/Skoruba.IdentityServer4.STS.Identity/Services/SendgridEmailSender.cs
View file @
5f641640
...
...
@@ -6,13 +6,13 @@ using System.Threading.Tasks;
namespace
Skoruba.IdentityServer4.STS.Identity.Services
{
public
class
Send
G
rid
M
ail
ingService
:
IEmailSender
public
class
Send
g
rid
Em
ail
Sender
:
IEmailSender
{
private
ISendGridClient
_client
;
private
readonly
SendgridConfiguration
_configuration
;
private
readonly
ILogger
<
Send
G
rid
M
ail
ingService
>
_logger
;
private
readonly
ILogger
<
Send
g
rid
Em
ail
Sender
>
_logger
;
public
Send
G
rid
M
ail
ingService
(
ILogger
<
Send
G
rid
M
ail
ingService
>
logger
,
ISendGridClient
client
,
SendgridConfiguration
configuration
)
public
Send
g
rid
Em
ail
Sender
(
ILogger
<
Send
g
rid
Em
ail
Sender
>
logger
,
ISendGridClient
client
,
SendgridConfiguration
configuration
)
{
_logger
=
logger
;
_client
=
client
;
...
...
This diff is collapsed.
Click to expand it.
src/Skoruba.IdentityServer4.STS.Identity/Startup.cs
View file @
5f641640
...
...
@@ -36,6 +36,7 @@ namespace Skoruba.IdentityServer4.STS.Identity
public
void
ConfigureServices
(
IServiceCollection
services
)
{
services
.
AddDbContexts
<
AdminDbContext
>(
Configuration
);
services
.
AddEmailSenders
(
Configuration
);
services
.
AddAuthenticationServices
<
AdminDbContext
,
UserIdentity
,
UserIdentityRole
>(
Environment
,
Configuration
,
Logger
);
services
.
AddMvcLocalization
();
}
...
...
This diff is collapsed.
Click to expand it.
src/Skoruba.IdentityServer4.STS.Identity/appsettings.json
View file @
5f641640
{
"ConnectionStrings"
:
{
"AdminConnection"
:
"Server=(localdb)
\\
mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Serilog"
:
{
"MinimumLevel"
:
"Information"
,
"WriteTo"
:
[
{
"Name"
:
"File"
,
"Args"
:
{
"path"
:
"Log
\\
skoruba_admin.txt"
,
"rollingInterval"
:
"Day"
}
},
{
"Name"
:
"MSSqlServer"
,
"Args"
:
{
"connectionString"
:
"Server=(localdb)
\\
mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
,
"tableName"
:
"Log"
,
"columnOptionsSection"
:
{
"addStandardColumns"
:
[
"LogEvent"
],
"removeStandardColumns"
:
[
"Properties"
]
}
}
}
]
},
"CertificateConfiguration"
:
{
"ConnectionStrings"
:
{
"AdminConnection"
:
"Server=(localdb)
\\
mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Serilog"
:
{
"MinimumLevel"
:
"Information"
,
"WriteTo"
:
[
{
"Name"
:
"File"
,
"Args"
:
{
"path"
:
"Log
\\
skoruba_admin.txt"
,
"rollingInterval"
:
"Day"
}
},
{
"Name"
:
"MSSqlServer"
,
"Args"
:
{
"connectionString"
:
"Server=(localdb)
\\
mssqllocaldb;Database=IdentityServer4Admin;Trusted_Connection=True;MultipleActiveResultSets=true"
,
"tableName"
:
"Log"
,
"columnOptionsSection"
:
{
"addStandardColumns"
:
[
"LogEvent"
],
"removeStandardColumns"
:
[
"Properties"
]
}
}
}
]
},
"CertificateConfiguration"
:
{
"UseTemporarySigningKeyForDevelopment"
:
true
,
"UseTemporarySigningKeyForDevelopment"
:
true
,
"UseSigningCertificateThumbprint"
:
false
,
"SigningCertificateThumbprint"
:
""
,
"UseSigningCertificateThumbprint"
:
false
,
"SigningCertificateThumbprint"
:
""
,
"UseSigningCertificatePfxFile"
:
false
,
"SigningCertificatePfxFilePath"
:
""
,
"SigningCertificatePfxFilePassword"
:
""
,
"UseSigningCertificatePfxFile"
:
false
,
"SigningCertificatePfxFilePath"
:
""
,
"SigningCertificatePfxFilePassword"
:
""
,
"UseValidationCertificatePfxFile"
:
false
,
"ValidationCertificatePfxFilePath"
:
""
,
"ValidationCertificatePfxFilePassword"
:
""
,
"UseValidationCertificatePfxFile"
:
false
,
"ValidationCertificatePfxFilePath"
:
""
,
"ValidationCertificatePfxFilePassword"
:
""
,
"UseValidationCertificateThumbprint"
:
false
,
"ValidationCertificateThumbprint"
:
""
},
"ExternalProvidersConfiguration"
:
{
"UseGitHubProvider"
:
false
,
"GitHubClientId"
:
""
,
"GitHubClientSecret"
:
""
}
"UseValidationCertificateThumbprint"
:
false
,
"ValidationCertificateThumbprint"
:
""
},
"ExternalProvidersConfiguration"
:
{
"UseGitHubProvider"
:
false
,
"GitHubClientId"
:
""
,
"GitHubClientSecret"
:
""
},
"SmtpConfiguration"
:
{
"Host"
:
""
,
"Login"
:
""
,
"Password"
:
""
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment