Compare commits

...

10 Commits

Author SHA1 Message Date
71b482edea 2020-11-29 19:47:10 +00:00
021ecc506a 2020-11-23 15:47:41 +00:00
2fe7364e85 Changed success page to look like old success page to make docs easier and reduce cognitive load on users 2019-10-15 18:48:18 +00:00
346540112e 2019-10-11 20:53:22 +00:00
5649332bf1 2019-10-07 23:43:29 +00:00
a4fb936d3f 2019-10-07 21:43:46 +00:00
b5735d3eb9 2019-10-07 19:38:50 +00:00
a6a02989e2 2019-10-04 17:59:59 +00:00
4b9f24e9e3 2019-10-02 20:27:19 +00:00
6438605fa0 2019-10-02 20:19:15 +00:00
6 changed files with 56 additions and 27 deletions

2
.vscode/launch.json vendored
View File

@@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/qbridge.dll",
"program": "${workspaceFolder}/bin/Debug/net5.0/qbridge.dll",
"args": [],
"cwd": "${workspaceFolder}",
//Launch browser is deprecated, this was copied from RAVEN but is no longer how it's done.

View File

@@ -14,16 +14,25 @@ namespace qbridge.Controllers
[Produces("application/json")]
public class OAuthRedirectController : ControllerBase
{
public const string CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
public const string CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
#if (DEBUG)
//SANDBOX
public const string CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
public const string CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
public const string REDIRECT_URI = "https://localhost:3003/redirect";
public const string DISCOVERY_DOCUMENT_URL = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration";
#else
public const string REDIRECT_URI = "https://qboauth.ayanova.com/redirect";
//PRODUCTION
public const string CLIENT_ID = "ABdUcQuZU9RJuVta7Jqbul85LnTpBwuR54hmvgAMn7NnZOuZam";
public const string CLIENT_SECRET = "iKd71iFV4PTaSlm22jB084RuiDIXcFfIEaOp88n4";
public const string DISCOVERY_DOCUMENT_URL = "https://developer.api.intuit.com/.well-known/openid_configuration";
#endif
public const string DISCOVERY_DOCUMENT_URL = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration";
public static Dictionary<string, QBToken> TOKEN_STORE = null;
//current 2019 fall disco doc urls
@@ -75,13 +84,19 @@ namespace qbridge.Controllers
}
[HttpGet("start/{state}")]
public async Task<IActionResult> GetAsync([FromRoute]string state)
[HttpGet("start/{state}/{sourceid}")]
public async Task<IActionResult> GetAsync([FromRoute]string state, [FromRoute] string sourceid)
{
//sourceid is actually the license ID or serial number so I can tell who is using and ultimately filter them out if they are not licensed and up to date (down the road, not initially)
if (string.IsNullOrWhiteSpace(state))
{
return BadRequest("state value is required");
return BadRequest("First parameter value");
}
if (string.IsNullOrWhiteSpace(sourceid))
{
return BadRequest("Second parameter value");
}
//Job one is to clean out the old entries in the token store if necessary
@@ -123,8 +138,6 @@ namespace qbridge.Controllers
//This Code value is the "Authorization code" that is then used to get the access token
//which in turn is *then* used to actually get the access token
}
@@ -184,6 +197,9 @@ namespace qbridge.Controllers
var access_token_expires_in = AccessTokenObject["expires_in"].Value<long>();
//Store the token!!
//Remove any prior tokens with same state if exist (this can happen if person reloads the auth page or navigates backwards in it)
TOKEN_STORE.Remove(state);
//now add it
TOKEN_STORE.Add(state, new QBToken() { realmId = realmId, access_token = access_token, refresh_token = refresh_token, TokenBirthday = DateTime.Now });
return Redirect("/success");
}
@@ -213,7 +229,7 @@ namespace qbridge.Controllers
[HttpGet("success")]
public IActionResult SuccessPage()
{
return ContentPage("<h2>Success!</h2>Token received from QuickBooks online and available for QBOI to automatically retrieve. You can close this browser window now.");
return ContentPage("<h1 style=\"color:#008000;\">Success!</h1>You have authorized the application to connect to your QuickBooks online.<br/><br/>You can close this browser page now.");
}
@@ -248,6 +264,7 @@ namespace qbridge.Controllers
}
public class QBToken
{
public string realmId { get; set; }

View File

@@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace qbridge.Controllers

View File

@@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace qbridge
{
@@ -18,12 +18,12 @@ namespace qbridge
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers().AddNewtonsoftJson();
services.AddHttpClient();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
@@ -31,12 +31,21 @@ namespace qbridge
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseRouting();
// app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseHttpsRedirection();
app.UseMvc();
// app.UseMvc();
}
}
}

View File

@@ -21,13 +21,18 @@ DEPLOYMENT qboauth.ayanova.com
publish command line from C:\data\code\qbridge folder:
//this will build a release version which is what we use on the server now
dotnet publish -c Release -o ./../publish/
//DEPRECATED dotnet publish -c Release -o ./../publish/
//this will build for our ubunutu linux server
dotnet publish -c Release -o ./../publish/ --no-self-contained -r linux-x64
//if need a debug version
dotnet publish -o ./../publish/
3) COPY
## MAKE BACKUP FIRST: cp -R pecklist pecklist_backup
Copy over to production server, only need the .dll and the wwwroot folder contents,
remember not to delete the folders on the server only replace their contents because there are file permissions set
Backup the database

View File

@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!-- <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" /> -->
<!-- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" /> -->
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0" />
<!-- <PackageReference Include="jose-jwt" Version="2.6.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" /> -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>
</Project>