-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# EditorConfig: https://EditorConfig.org | ||
|
||
root = true | ||
|
||
# All Files | ||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# XML Configuration Files | ||
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct,refactorlog,runsettings}] | ||
indent_size = 2 | ||
|
||
# JSON Files | ||
[*.{json,json5,webmanifest}] | ||
indent_size = 2 | ||
|
||
# Project Files | ||
[*.{csproj,sqlproj}] | ||
indent_size = 2 | ||
|
||
# YAML Files | ||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
# Markdown Files | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
# Web Files | ||
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}] | ||
indent_size = 2 | ||
|
||
# Batch Files | ||
[*.{cmd,bat}] | ||
end_of_line = crlf | ||
|
||
# Bash Files | ||
[*.sh] | ||
end_of_line = lf | ||
|
||
[*.{cs,vb}] | ||
dotnet_sort_system_directives_first = true | ||
dotnet_separate_import_directive_groups = true | ||
dotnet_style_namespace_match_folder = true | ||
|
||
[*.cs] | ||
csharp_using_directive_placement = outside_namespace | ||
csharp_style_namespace_declarations = file_scoped:warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: nuget | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "11:00" | ||
open-pull-requests-limit: 10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Build | ||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | ||
DOTNET_ENVIRONMENT: github | ||
ASPNETCORE_ENVIRONMENT: github | ||
BUILD_PATH: '${{github.workspace}}/artifacts' | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
8.0.x | ||
- name: Restore Dependencies | ||
run: dotnet restore | ||
|
||
- name: Build Solution | ||
run: dotnet build --no-restore --configuration Release | ||
|
||
- name: Run Test | ||
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings | ||
|
||
- name: Report Coverage | ||
if: success() | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
file: "${{github.workspace}}/test/*/TestResults/*/coverage.info" | ||
format: lcov | ||
|
||
- name: Create Packages | ||
if: success() && github.event_name != 'pull_request' | ||
run: dotnet pack --configuration Release --include-symbols --include-source --no-build --output "${{env.BUILD_PATH}}" | ||
|
||
- name: Upload Packages | ||
if: success() && github.event_name != 'pull_request' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages | ||
path: "${{env.BUILD_PATH}}" | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: success() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) | ||
|
||
steps: | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: packages | ||
|
||
- name: Publish Packages GitHub | ||
run: | | ||
for package in $(find -name "*.nupkg"); do | ||
echo "${0##*/}": Pushing $package... | ||
dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | ||
done | ||
- name: Publish Packages feedz | ||
run: | | ||
for package in $(find -name "*.nupkg"); do | ||
echo "${0##*/}": Pushing $package... | ||
dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate | ||
done | ||
- name: Publish Packages Nuget | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
for package in $(find -name "*.nupkg"); do | ||
echo "${0##*/}": Pushing $package... | ||
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate | ||
done | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authorizone", "src\Authorizone\Authorizone.csproj", "{9CE78075-9509-4113-B645-45A082C68839}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authorizone.Tests", "test\Authorizone.Tests\Authorizone.Tests.csproj", "{DA3CCF24-533A-436A-9929-28AF83D29B32}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{4F71B12A-605F-48FE-94F5-FF3B776FEA6D}" | ||
ProjectSection(SolutionItems) = preProject | ||
src\Directory.Build.props = src\Directory.Build.props | ||
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9CE78075-9509-4113-B645-45A082C68839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9CE78075-9509-4113-B645-45A082C68839}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9CE78075-9509-4113-B645-45A082C68839}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9CE78075-9509-4113-B645-45A082C68839}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{DA3CCF24-533A-436A-9929-28AF83D29B32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DA3CCF24-533A-436A-9929-28AF83D29B32}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DA3CCF24-533A-436A-9929-28AF83D29B32}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DA3CCF24-533A-436A-9929-28AF83D29B32}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E07DA442-1D4F-4528-BB2E-29E884BFFA66} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<RunSettings> | ||
<DataCollectionRunSettings> | ||
<DataCollectors> | ||
<DataCollector friendlyName="XPlat code coverage"> | ||
<Configuration> | ||
<Format>lcov</Format> | ||
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,TestSDKAutoGeneratedCode</ExcludeByAttribute> | ||
<SkipAutoProps>true</SkipAutoProps> | ||
</Configuration> | ||
</DataCollector> | ||
</DataCollectors> | ||
</DataCollectionRunSettings> | ||
</RunSettings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Authorizone; | ||
|
||
public static class AuthorizationActions | ||
{ | ||
public const string All = "all"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Authorizone; | ||
|
||
public class AuthorizationBuilder | ||
{ | ||
private readonly List<AuthorizationRule> _rules = []; | ||
|
||
public AuthorizationBuilder Allow(string action, string subject, IEnumerable<string>? fields = null) | ||
{ | ||
if (string.IsNullOrWhiteSpace(action)) | ||
throw new ArgumentException("Action cannot be null or whitespace.", nameof(action)); | ||
|
||
if (string.IsNullOrWhiteSpace(subject)) | ||
throw new ArgumentException("Subject cannot be null or whitespace.", nameof(subject)); | ||
|
||
var rule = new AuthorizationRule(action, subject, fields?.ToList()); | ||
_rules.Add(rule); | ||
|
||
return this; | ||
} | ||
|
||
public AuthorizationBuilder Forbid(string action, string subject, IEnumerable<string>? fields = null) | ||
{ | ||
if (string.IsNullOrWhiteSpace(action)) | ||
throw new ArgumentException("Action cannot be null or whitespace.", nameof(action)); | ||
|
||
if (string.IsNullOrWhiteSpace(subject)) | ||
throw new ArgumentException("Subject cannot be null or whitespace.", nameof(subject)); | ||
|
||
var rule = new AuthorizationRule(action, subject, fields?.ToList(), true); | ||
_rules.Add(rule); | ||
|
||
return this; | ||
} | ||
|
||
public AuthorizationContext Build() | ||
{ | ||
return new AuthorizationContext(_rules); | ||
} | ||
} |
Oops, something went wrong.