-
-
Notifications
You must be signed in to change notification settings - Fork 748
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
15 changed files
with
77 additions
and
587 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/DefaultOpaDecision.cs
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,12 @@ | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public class DefaultOpaDecision : IOpaDecision | ||
{ | ||
public AuthorizeResult Map(ResponseBase? response) => response switch | ||
{ | ||
QueryResponse { Result: true } => AuthorizeResult.Allowed, | ||
NoDefaultPolicy => AuthorizeResult.NoDefaultPolicy, | ||
PolicyNotFound => AuthorizeResult.PolicyNotFound, | ||
_ => AuthorizeResult.NotAllowed | ||
}; | ||
} |
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
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
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
13 changes: 0 additions & 13 deletions
13
src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/OpaDecision.cs
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/OpaOptions.cs
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using System.Text.Json; | ||
using System.Text.Json; | ||
|
||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public sealed class OpaOptions | ||
{ | ||
public Uri BaseAddress { get; set; } = new Uri("http://127.0.0.1:8181"); | ||
public Uri BaseAddress { get; set; } = new("http://127.0.0.1:8181"); | ||
public TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromMilliseconds(250); | ||
public JsonSerializerOptions JsonSerializerOptions { get; set; } = new JsonSerializerOptions(); | ||
public JsonSerializerOptions JsonSerializerOptions { get; set; } = new(); | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Types/IOpaDecision.cs
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public interface IOpaDecision | ||
{ | ||
AuthorizeResult Map(QueryResponse? response); | ||
AuthorizeResult Map(ResponseBase? response); | ||
} |
8 changes: 8 additions & 0 deletions
8
...HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Types/IOpaQueryRequestFactory.cs
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,8 @@ | ||
using HotChocolate.Resolvers; | ||
|
||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public interface IOpaQueryRequestFactory | ||
{ | ||
QueryRequest CreateRequest(IMiddlewareContext context, AuthorizeDirective directive); | ||
} |
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
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
4 changes: 2 additions & 2 deletions
4
...etCore.Authorization.Opa/Types/GraphQl.cs → ...NetCore.Authorization.Opa/Types/Policy.cs
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public sealed class GraphQl | ||
public sealed class Policy | ||
{ | ||
public string Policy { get; set; } = string.Empty; | ||
public string Path { get; set; } = string.Empty; | ||
public string[] Roles { get; set; } = Array.Empty<string>(); | ||
} |
19 changes: 17 additions & 2 deletions
19
src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Types/QueryResponse.cs
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 |
---|---|---|
@@ -1,7 +1,22 @@ | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
namespace HotChocolate.AspNetCore.Authorization; | ||
|
||
public sealed class QueryResponse | ||
public abstract class ResponseBase { } | ||
|
||
public sealed class QueryResponse : ResponseBase | ||
{ | ||
public Guid? DecisionId { get; set; } | ||
public bool Result { get; set; } | ||
} | ||
|
||
public sealed class PolicyNotFound : ResponseBase | ||
{ | ||
private PolicyNotFound() {} | ||
public static readonly PolicyNotFound Response = new(); | ||
} | ||
|
||
|
||
public sealed class NoDefaultPolicy : ResponseBase | ||
{ | ||
private NoDefaultPolicy() { } | ||
public static readonly NoDefaultPolicy Response = new(); | ||
} |
Oops, something went wrong.