refactoring
This commit is contained in:
parent
6470cf9273
commit
fa85f1effc
7 changed files with 54 additions and 48 deletions
|
|
@ -127,13 +127,12 @@ namespace Yavsc
|
|||
options.AccessDeniedPath = new PathString(Constants.LoginPath.Substring(1));
|
||||
});
|
||||
|
||||
|
||||
|
||||
var gvents = new OAuthEvents();
|
||||
|
||||
YavscGoogleAppOptions = new YavscGoogleOptions
|
||||
{
|
||||
ClientId = Configuration["Authentication:Google:ServiceAccount:client_id"],
|
||||
ClientSecret = Configuration["Authentication:Google:ServiceAccount:client_secret"],
|
||||
ClientId = GoogleWebClientConfiguration ["web:client_id"],
|
||||
ClientSecret = GoogleWebClientConfiguration ["web:client_secret"],
|
||||
AccessType = "offline",
|
||||
Scope = { "profile", "https://www.googleapis.com/auth/plus.login",
|
||||
"https://www.googleapis.com/auth/admin.directory.resource.calendar",
|
||||
|
|
|
|||
|
|
@ -48,19 +48,6 @@ namespace Yavsc
|
|||
logger.LogWarning("It has been set to : "+Environment.GetEnvironmentVariable("APPDATA"));
|
||||
}
|
||||
|
||||
var creds = GoogleSettings?.ServiceAccount?.private_key;
|
||||
if (creds==null)
|
||||
throw new InvalidOperationException("No Google API credential");
|
||||
foreach (var feature in app.ServerFeatures)
|
||||
{
|
||||
var val = JsonConvert.SerializeObject(feature.Value);
|
||||
logger.LogInformation( $"#Feature {feature.Key}: {val}" );
|
||||
}
|
||||
foreach (var prop in app.Properties)
|
||||
{
|
||||
var val = JsonConvert.SerializeObject(prop.Value);
|
||||
logger.LogInformation( $"#Property {prop.Key}: {val}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ using Microsoft.Extensions.Logging;
|
|||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
|
@ -43,6 +44,7 @@ namespace Yavsc
|
|||
public static string Authority { get; private set; }
|
||||
public static string Temp { get; set; }
|
||||
public static SiteSettings SiteSetup { get; private set; }
|
||||
public static GoogleServiceAccount GServiceAccount { get; private set; }
|
||||
|
||||
public static string HostingFullName { get; set; }
|
||||
|
||||
|
|
@ -76,11 +78,20 @@ namespace Yavsc
|
|||
var auth = Configuration["Site:Authority"];
|
||||
var cxstr = Configuration["Data:DefaultConnection:ConnectionString"];
|
||||
ConnectionString = cxstr;
|
||||
|
||||
AppDomain.CurrentDomain.SetData(Constants.YavscConnectionStringEnvName, ConnectionString);
|
||||
|
||||
var googleClientFile = Configuration["Authentication:Google:GoogleWebClientJson"];
|
||||
var googleServiceAccountJsonFile = Configuration["Authentication:Google:GoogleServiceAccountJson"];
|
||||
GoogleWebClientConfiguration = new ConfigurationBuilder().AddJsonFile(googleClientFile).Build();
|
||||
var safile = new FileInfo(googleServiceAccountJsonFile);
|
||||
GServiceAccount = JsonConvert.DeserializeObject<GoogleServiceAccount>(safile.OpenText().ReadToEnd());
|
||||
}
|
||||
|
||||
public static string ConnectionString { get; set; }
|
||||
public static GoogleAuthSettings GoogleSettings { get; set; }
|
||||
public IConfigurationRoot Configuration { get; set; }
|
||||
public static IConfigurationRoot GoogleWebClientConfiguration { get; set; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue