Definition
Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Models Inheritance: System.ObjectSyntax
Summary
Defines scope requirements for operations on a specific entity type.Remarks
Entity scope requirements allow fine-grained authorization control at the entity level, enabling different access policies for different types of data within the same OData service.Constructors
.ctor
Initializes a new instance of the EntityScopeRequirements class.Syntax
.ctor
Initializes a new instance of the EntityScopeRequirements class with the same scopes for all operations.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
allOperationsScopes | System.Collections.Generic.IEnumerable<string> | The scopes required for all operations on this entity. |
Exceptions
| Exception | Description |
|---|---|
ArgumentNullException | Thrown when allOperationsScopes is null. |
.ctor
Initializes a new instance of the EntityScopeRequirements class with separate read and write scopes.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
readScopes | System.Collections.Generic.IEnumerable<string> | The scopes required for read operations. |
writeScopes | System.Collections.Generic.IEnumerable<string> | The scopes required for write operations. |
Exceptions
| Exception | Description |
|---|---|
ArgumentNullException | Thrown when readScopes or writeScopes is null. |
.ctor Inherited
Inherited from
objectSyntax
Properties
CreateScopes
Gets or sets the scopes required for creating entities of this type.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow create access to the entity.
Remarks
Users must have at least one of these scopes to create new instances of this entity type.CustomOperationScopes
Gets or sets custom scope requirements for specific operations.Syntax
Property Value
Type:System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>
A mapping of custom operation names to their required scopes.
Remarks
This allows defining scope requirements for custom operations beyond the standard CRUD operations. The operation names should match those used in the MCP tool definitions.DeleteScopes
Gets or sets the scopes required for deleting entities of this type.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow delete access to the entity.
Remarks
Users must have at least one of these scopes to delete instances of this entity type.NavigateScopes
Gets or sets the scopes required for navigating to related entities.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow navigation to related entities.
Remarks
Users must have at least one of these scopes to follow navigation properties from this entity type to related entities.QueryScopes
Gets or sets the scopes required for querying entities of this type.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow query access to the entity.
Remarks
Users must have at least one of these scopes to perform complex queries, filtering, and sorting on this entity type.ReadScopes
Gets or sets the scopes required for reading entities of this type.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow read access to the entity.
Remarks
Users must have at least one of these scopes to query, retrieve, or navigate to entities of this type.UpdateScopes
Gets or sets the scopes required for updating entities of this type.Syntax
Property Value
Type:System.Collections.Generic.List<string>
A collection of scopes that allow update access to the entity.
Remarks
Users must have at least one of these scopes to modify existing instances of this entity type.Methods
AddCustomOperation
Adds a custom operation with its required scopes.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
operationName | string | The name of the custom operation. |
scopes | System.Collections.Generic.IEnumerable<string> | The required scopes for the operation. |
Exceptions
| Exception | Description |
|---|---|
ArgumentException | Thrown when operationName is null or whitespace. |
ArgumentNullException | Thrown when scopes is null. |
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | - |
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
GetAllScopes
Gets all unique scopes defined for this entity across all operations.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of all unique scopes defined for this entity.
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetScopesForOperation
Gets the required scopes for a specific operation.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
operation | string | The operation name (e.g., “read”, “create”, “update”, “delete”, “query”, “navigate”). |
Returns
Type:System.Collections.Generic.IEnumerable<string>
The required scopes for the operation, or an empty collection if no specific requirement exists.
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
HasAnyScopes
Determines whether any scopes are defined for this entity.Syntax
Returns
Type:bool
true if any scopes are defined; otherwise, false.
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
SetScopesForOperation
Sets the required scopes for a specific operation.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
operation | string | The operation name. |
scopes | System.Collections.Generic.IEnumerable<string> | The required scopes for the operation. |
Exceptions
| Exception | Description |
|---|---|
ArgumentException | Thrown when operation is null or whitespace. |
ArgumentNullException | Thrown when scopes is null. |
ToString Override
Returns a string representation of the entity scope requirements.Syntax
Returns
Type:string
A summary of the scope requirements for this entity.
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Validate
Validates the entity scope requirements for consistency and completeness.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of validation errors, or an empty collection if the requirements are valid.