-
Notifications
You must be signed in to change notification settings - Fork 357
Bind database policy claims as typed OData constants #3756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aaronburtle
wants to merge
6
commits into
main
Choose a base branch
from
dev/aaronburtle/fix-odata-filter-injection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f6d2c4a
safely inject claims
aaronburtle 170c282
fix some missing operator paths
aaronburtle 118417b
fix bugs
aaronburtle 60f660d
remove obsolete method
aaronburtle cbe4828
Merge branch 'main' into dev/aaronburtle/fix-odata-filter-injection
aaronburtle 6e34f4d
Merge branch 'main' into dev/aaronburtle/fix-odata-filter-injection
aaronburtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,46 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Azure.DataApiBuilder.Auth; | ||
|
|
||
| /// <summary> | ||
| /// A database authorization policy whose claim references have been replaced by | ||
| /// OData parameter aliases. Claim values remain separate from the policy text so | ||
| /// they can be injected into the parsed OData AST as typed constants. | ||
| /// </summary> | ||
| public sealed record ResolvedDatabasePolicy | ||
| { | ||
| /// <summary> | ||
| /// Policy text containing OData parameter aliases. | ||
| /// </summary> | ||
| public string Policy { get; } | ||
|
|
||
| /// <summary> | ||
| /// Immutable snapshot of typed claim values keyed by parameter alias. | ||
| /// </summary> | ||
| public IReadOnlyDictionary<string, object?> ClaimValues { get; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a resolved database policy and takes an immutable snapshot of its claim values. | ||
| /// </summary> | ||
| /// <param name="policy">Policy text containing OData parameter aliases.</param> | ||
| /// <param name="claimValues">Typed claim values keyed by their parameter alias.</param> | ||
| public ResolvedDatabasePolicy(string policy, IReadOnlyDictionary<string, object?> claimValues) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(policy); | ||
| ArgumentNullException.ThrowIfNull(claimValues); | ||
|
|
||
| Policy = policy; | ||
| ClaimValues = new ReadOnlyDictionary<string, object?>( | ||
| new Dictionary<string, object?>(claimValues, StringComparer.Ordinal)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Represents an operation without a database authorization policy. | ||
| /// </summary> | ||
| public static ResolvedDatabasePolicy Empty { get; } = new( | ||
|
aaronburtle marked this conversation as resolved.
|
||
| string.Empty, | ||
| new ReadOnlyDictionary<string, object?>(new Dictionary<string, object?>())); | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.