Skip to content

Commit

Permalink
(#2) add cors
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Sep 27, 2024
1 parent ffd419c commit 4f591d7
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/Core/CorsEnvironment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Nuar.Cors.Core
{
public class CorsEnvironment
{
public IEnumerable<string> AllowedOrigins { get; set; }
}
}
21 changes: 21 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/CorsOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Nuar.Cors.Core;

namespace Nuar.Cors
{
public class CorsOptions
{
public bool AllowCredentials { get; set; }
public IEnumerable<string> AllowedOrigins { get; set; }
public IEnumerable<string> DeniedOrigins { get; set; }
public IEnumerable<string> AllowedMethods { get; set; }
public IEnumerable<string> AllowedHeaders { get; set; }
public IEnumerable<string> ExposedHeaders { get; set; }
public int? MaxAge { get; set; }
public bool LoggingEnabled { get; set; }
public Dictionary<string, CorsEnvironment> Environment { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nuar.Cors", "Nuar.Cors.csproj", "{12826F29-A48B-4550-A24F-892A2DC09CC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12826F29-A48B-4550-A24F-892A2DC09CC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12826F29-A48B-4550-A24F-892A2DC09CC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12826F29-A48B-4550-A24F-892A2DC09CC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12826F29-A48B-4550-A24F-892A2DC09CC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F0641B95-4B9A-4328-95A1-8A3CDFD884DE}
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/cors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cors:
allowCredentials: true
allowedOrigins:
- '*'
deniedOrigins:
- 'http://disallowed-origin.com'
allowedMethods:
- get
- post
- delete
allowedHeaders:
- '*'
exposedHeaders:
- Request-ID
- Resource-ID
- Trace-ID
- Total-Count
maxAge: 3600
loggingEnabled: true
environment:
development:
allowedOrigins:
- 'http://localhost:3000'
production:
allowedOrigins:
- 'https://my-production-domain.com'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Nuar.Cors")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ffd419cb94da23dfe0244e2eeb5ed393e94d8d36")]
[assembly: System.Reflection.AssemblyProductAttribute("Nuar.Cors")]
[assembly: System.Reflection.AssemblyTitleAttribute("Nuar.Cors")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb691fae5e8ff7ce111567c6ee56426d511e58d292f5e1863854ae2fe85b0dfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Nuar.Cors
build_property.ProjectDir = /home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
68 changes: 68 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/obj/Nuar.Cors.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"format": 1,
"restore": {
"/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj": {}
},
"projects": {
"/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj",
"projectName": "Nuar.Cors",
"projectPath": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj",
"packagesPath": "/home/kaliuser/.nuget/packages/",
"outputPath": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/kaliuser/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {},
"https://nuget.pkg.github.com/CRMLXRMS-Labs/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/kaliuser/dotnet/sdk/9.0.100-rc.1.24452.12/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
15 changes: 15 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/obj/Nuar.Cors.csproj.nuget.g.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/kaliuser/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/kaliuser/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/kaliuser/.nuget/packages/" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
73 changes: 73 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/obj/project.assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/kaliuser/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj",
"projectName": "Nuar.Cors",
"projectPath": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj",
"packagesPath": "/home/kaliuser/.nuget/packages/",
"outputPath": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/kaliuser/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {},
"https://nuget.pkg.github.com/CRMLXRMS-Labs/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/kaliuser/dotnet/sdk/9.0.100-rc.1.24452.12/PortableRuntimeIdentifierGraph.json"
}
}
}
}
8 changes: 8 additions & 0 deletions src/Nuar.Cors/src/Nuar.Cors/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "f+R55JhnPBc=",
"success": true,
"projectFilePath": "/home/kaliuser/Documents/portfolio/commercial_apps/crmlxrms/nuar_framework/src/Nuar.Cors/src/Nuar.Cors/Nuar.Cors.csproj",
"expectedPackageFiles": [],
"logs": []
}

0 comments on commit 4f591d7

Please sign in to comment.