Version 1.0.5-rc22

This commit is contained in:
2018-07-26 17:10:57 +02:00
parent 82f1d80e5f
commit 77bad2356e
13 changed files with 171 additions and 44 deletions

View File

@ -1,12 +1,18 @@
{
"Site": {
"Authority": "dev.pschneider.fr",
"Title": "Yavsc dev",
"Slogan": "Yavsc : WIP.",
"Banner": "/images/yavsc.png",
"HomeViewName": "Home",
"FavIcon": "/favicon.ico",
"Icon": "/images/yavsc.png"
"ConnectionSettings" : {
"Site": {
"Authority": "oauth.server-example.com",
"Title": "[Site title]",
"Slogan": "[Site Slogan]",
"Banner": "/images/[bannerAsset]",
"HomeViewName": "Home",
"FavIcon": "/favicon.ico",
"Icon": "/images/[Site Icon]"
},
"ServerApiKey": {
"ClientId": "[OAuth2NativeClientId]",
"ClientSecret": "[OAuth2ClientSecret]"
}
},
"Logging": {
"IncludeScopes": true,
@ -18,7 +24,7 @@
},
"Data": {
"DefaultConnection": {
"ConnectionString": "Server=localhost;Port=5432;Database=YavscDev;Username=yavscdev;Password=admin;"
"ConnectionString": "[sbConStr]"
}
}
}

View File

@ -45,15 +45,15 @@
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"Newtonsoft.Json": "9.0.1",
"Yavsc": {
"version": "1.0.5-rc21-beta9",
"version": "1.0.5-rc22",
"target": "package"
},
"Yavsc.Abstract": {
"version": "1.0.5-rc21-beta9",
"version": "1.0.5-rc22",
"target": "package"
},
"Yavsc.Server": {
"version": "1.0.5-rc21-beta9",
"version": "1.0.5-rc22",
"target": "package"
},
"Yavsc.Lib.Portable": "1.0.2"

View File

@ -0,0 +1,56 @@
namespace cli
{
using Yavsc.Abstract.Identity;
using Yavsc;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Yavsc.Authentication;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
public class ConnectionSettings
{
public TokenInfo UserToken { get; set; }
public SiteSettings Site { get; set; }
public OAuth2AppSettings ServerApiKey { get; set; }
public string SiteAccessSheme { get; set; } = "http";
public string Scope { get; set; } = "profile";
[NotMapped]
[JsonIgnore]
public string AuthorizeUrl {get {
return $"{SiteAccessSheme}://{Site.Authority}/authorize";
} }
[NotMapped]
[JsonIgnore]
public string RedirectUrl {get {
return $"{SiteAccessSheme}://{Site.Authority}/oauth/success";
} }
[NotMapped]
[JsonIgnore]
public string AccessTokenUrl {get {
return $"{SiteAccessSheme}://{Site.Authority}/token";
} }
public async Task InitUserTokenFromLoginPass(string login, string pass)
{
var oauthor =new OAuthenticator( ServerApiKey.ClientId, ServerApiKey.ClientSecret, Scope,
new Uri( AuthorizeUrl) , new Uri(RedirectUrl) , new Uri(AccessTokenUrl));
var query = new Dictionary<string,string>();
query["username"]=login;
query["password"]=pass;
query["grant_type"]="password";
var result = await oauthor.RequestAccessTokenAsync(query);
UserToken = new TokenInfo {
AccessToken = result["access_token"],
RefreshToken = result["refresh_token"],
Received = DateTime.Now,
ExpiresIn = int.Parse(result["expires_in"]),
TokenType = result["token_type"]
};
}
}
}

View File

@ -4,6 +4,8 @@ using Microsoft.Extensions.Logging;
// using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using cli.Services;
using Microsoft.Extensions.CommandLineUtils;
using System;
namespace cli
{
@ -11,20 +13,59 @@ namespace cli
{
public static void Main(string[] args)
{
var host = new WebHostBuilder();
var hostengnine = host
.UseEnvironment("Development")
.UseServer("cli")
.UseStartup<Startup>()
.Build();
CommandArgument sendMailCommandArg=null;
CommandLineApplication sendMailCommand=null;
CommandOption sendHelpOption=null;
CommandOption rootCommandHelpOption = null;
CommandLineApplication cliapp = new CommandLineApplication(false);
cliapp.Name = "cli";
cliapp.FullName = "Yavsc command line interface";
cliapp.Description = "Dnx console for yavsc server side";
cliapp.ShortVersionGetter = () => "v1.0";
cliapp.LongVersionGetter = () => "version 1.0 (stable)";
rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
sendMailCommand = cliapp.Command("send",
(target) => {
target.FullName="Send email";
target.Description="Sends emails using given template";
sendHelpOption = target.HelpOption("-? | -h | --help");
sendMailCommandArg = target.Argument(
"class",
"class name of mailling to execute (actually, only 'monthly') .",
multipleValues: true);
}, false);
var app = hostengnine.Start();
var mailer = app.Services.GetService<EMailer>();
var loggerFactory = app.Services.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Program>();
mailer.SendMonthlyEmail(1,"UserOrientedTemplate");
logger.LogInformation("Finished");
sendMailCommand.OnExecute(() =>
{
if (sendMailCommandArg.Value == "monthly")
{
var host = new WebHostBuilder();
var hostengnine = host.UseEnvironment("Development")
.UseServer("cli")
.UseStartup<Startup>()
.Build();
var app = hostengnine.Start();
var mailer = app.Services.GetService<EMailer>();
var loggerFactory = app.Services.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Starting emailling");
mailer.SendMonthlyEmail(1, "UserOrientedTemplate");
logger.LogInformation("Finished emailling");
}
else
{
sendMailCommand.ShowHelp();
}
return 0;
});
cliapp.Execute(args);
if (args.Length==0 || cliapp.RemainingArguments.Count>0)
cliapp.ShowHint();
}
}
}

View File

@ -3,7 +3,6 @@ using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

View File

@ -1,5 +1,4 @@
using System;
using Microsoft.AspNet.Razor;
using Microsoft.AspNet.Razor;
namespace cli
{

View File

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Hosting.Server;
using Microsoft.AspNet.Http.Features;
using Microsoft.Extensions.Configuration;
using Yavsc.Models;
namespace Yavsc.Server
{