Skip to content
This repository has been archived by the owner on Apr 10, 2021. It is now read-only.

Commit

Permalink
GraphQL Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
keggyy committed Feb 23, 2019
1 parent cfbc180 commit a5a0c88
Show file tree
Hide file tree
Showing 85 changed files with 2,091 additions and 340 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -51,6 +51,10 @@ All kind of help is welcome, so if you want to fork and propose some changes you
### Dev environment
We will use VS2017 community as our main IDE and Windows 10 as development platform, VS code for UI part.

Required plugin on VS2017:
- [license manager](https://marketplace.visualstudio.com/items?itemName=StefanWenig.LicenseHeaderManager)
- [Code refacroting](https://marketplace.visualstudio.com/items?itemName=SteveCadwallader.CodeMaid)

Repository structure will be the following:
-ROOT
- docs
Expand Down
829 changes: 669 additions & 160 deletions LICENSE

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/AuthPlugin.cs
@@ -1,4 +1,12 @@
using IdentityModel.AspNetCore.OAuth2Introspection;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using IdentityModel.AspNetCore.OAuth2Introspection;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Configuration/AuthConfig.cs
@@ -1,4 +1,12 @@
using IdentityServer4;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using IdentityServer4;
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Security.Claims;
Expand Down
@@ -1,4 +1,12 @@
namespace RawCMS.Plugins.Core.Configuration
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
namespace RawCMS.Plugins.Core.Configuration
{
public class ConfigurationOptions
{
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Controllers/CRUDController.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Mvc;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using RawCMS.Library.Core;
using RawCMS.Library.Core.Attributes;
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Controllers/LambdaController.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Authorization;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using RawCMS.Library.Core;
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Controllers/admin/AdminController.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Mvc;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Mvc;
using RawCMS.Library.Core;
using RawCMS.Library.Core.Attributes;

Expand Down
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Mvc;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Mvc;

namespace RawCMS.Plugins.Core.Controllers.Controllers.admin
{
Expand Down
24 changes: 15 additions & 9 deletions Plugins/RawCMS.Plugin.Core/CorePlugin.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Builder;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -27,15 +35,15 @@ public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);

services.AddOptions();

services.AddOptions();

Logger.LogInformation(configuration["MongoSettings:ConnectionString"]);

MongoSettings instance = new MongoSettings();
instance.ConnectionString = configuration["MongoSettings:ConnectionString"];
instance.DBName = configuration["MongoSettings:DBName"];

MongoSettings instance = new MongoSettings
{
ConnectionString = configuration["MongoSettings:ConnectionString"],
DBName = configuration["MongoSettings:DBName"]
};

IOptions<MongoSettings> settingsOptions = Options.Create<MongoSettings>(instance);
MongoService mongoService = new MongoService(settingsOptions, Logger);
Expand All @@ -53,7 +61,6 @@ public override void ConfigureServices(IServiceCollection services)
Engine.Plugins.ForEach(x => SetConfiguration(x, crudService));

crudService.EnsureCollection("_schema");

}

private void SetConfiguration(Plugin plugin, CRUDService crudService)
Expand Down Expand Up @@ -98,7 +105,6 @@ public override void Configure(IApplicationBuilder app, AppEngine appEngine)
base.Configure(app, appEngine);
}


private IConfigurationRoot configuration;

public override void Setup(IConfigurationRoot configuration)
Expand Down
@@ -1,4 +1,12 @@
using IdentityServer4.Services;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using IdentityServer4.Services;
using Microsoft.Extensions.DependencyInjection;
using RawCMS.Plugins.Core.Stores;

Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Lambdas/UserInfoLambda.cs
@@ -1,4 +1,12 @@
using Newtonsoft.Json.Linq;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Newtonsoft.Json.Linq;
using RawCMS.Library.Core;
using System;

Expand Down
12 changes: 10 additions & 2 deletions Plugins/RawCMS.Plugin.Core/MVC/RawAuthorizationHandler.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Http;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Security.Claims;
Expand Down Expand Up @@ -27,7 +35,7 @@ public override void OnActionExecuting(ActionExecutingContext context)

bool isAdmin = context.HttpContext.Request.Path.Value.StartsWith("system/");
bool requiresAdminKey = (isAdmin && !string.IsNullOrWhiteSpace(adminapikey));
bool requiresPublicKey=!isAdmin && !string.IsNullOrWhiteSpace(apikey);
bool requiresPublicKey = !isAdmin && !string.IsNullOrWhiteSpace(apikey);
bool requiresAuth = requiresPublicKey || requiresAdminKey;

if (requiresAdminKey && context.HttpContext.Request.Headers["Authorization"] == apikey)
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Model/IdentityRole.cs
@@ -1,4 +1,12 @@
namespace RawCMS.Plugins.Core.Model
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
namespace RawCMS.Plugins.Core.Model
{
public class IdentityRole
{
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Model/IdentityUser.cs
@@ -1,4 +1,12 @@
using Newtonsoft.Json;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Model/RestMessage.cs
@@ -1,4 +1,12 @@
using RawCMS.Library.Core;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using RawCMS.Library.Core;
using System.Collections.Generic;

namespace RawCMS.Plugins.Core.Model
Expand Down
1 change: 1 addition & 0 deletions Plugins/RawCMS.Plugin.Core/RawCMS.Plugins.Core.csproj
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="IdentityServer4" Version="2.2.0" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.1.0" />
Expand Down
11 changes: 8 additions & 3 deletions Plugins/RawCMS.Plugin.Core/SecurityHeadersAttribute.cs
@@ -1,6 +1,11 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/Stores/RawRoleStore.cs
@@ -1,4 +1,12 @@
using Microsoft.AspNetCore.Identity;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down
19 changes: 13 additions & 6 deletions Plugins/RawCMS.Plugin.Core/Stores/RawUserStore.cs
@@ -1,4 +1,12 @@
using IdentityServer4.Models;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using IdentityServer4.Models;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -32,7 +40,7 @@ public async Task<IList<Claim>> GetClaimsAsync(IdentityUser user)
foreach (JProperty key in userObj.Properties())
{
if (key.HasValues && !key.Name.Contains("Password"))
{
{
claims.Add(new Claim(key.Name, key.Value.ToString()));
}
}
Expand Down Expand Up @@ -129,7 +137,6 @@ public async Task<IdentityUser> FindByIdAsync(string userId, CancellationToken c

public async Task<IdentityUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
{

DataQuery query = new DataQuery()
{
RawQuery = JsonConvert.SerializeObject(new { NormalizedUserName = normalizedUserName })
Expand Down Expand Up @@ -166,16 +173,16 @@ public async Task SetNormalizedUserNameAsync(IdentityUser user, string normalize

public async Task InitData()
{
var count = 0l;
long count = 0L;
try
{
count = this.service.Count(collection, null);
count = service.Count(collection, null);
}
catch
{
//no error if missing collection
}
if (count==0)
if (count == 0)
{
IdentityUser userToAdd = new IdentityUser()
{
Expand Down
10 changes: 9 additions & 1 deletion Plugins/RawCMS.Plugin.Core/UserCheckLambda.cs
@@ -1,4 +1,12 @@
using Newtonsoft.Json.Linq;
//******************************************************************************
// <copyright file="license.md" company="RawCMS project (https://github.com/arduosoft/RawCMS)">
// Copyright (c) 2019 RawCMS project (https://github.com/arduosoft/RawCMS)
// RawCMS project is released under GPL3 terms, see LICENSE file on repository root at https://github.com/arduosoft/RawCMS .
// </copyright>
// <author>Daniele Fontani, Emanuele Bucarelli, Francesco Min�</author>
// <autogenerated>true</autogenerated>
//******************************************************************************
using Newtonsoft.Json.Linq;
using RawCMS.Library.Core;

namespace RawCMS.Plugins.Core
Expand Down

0 comments on commit a5a0c88

Please sign in to comment.