Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Models Inheritance: System.Object

Syntax

Microsoft.OData.Mcp.Authentication.Models.EntityScopeRequirements

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

public EntityScopeRequirements()

.ctor

Initializes a new instance of the EntityScopeRequirements class with the same scopes for all operations.

Syntax

public EntityScopeRequirements(System.Collections.Generic.IEnumerable<string> allOperationsScopes)

Parameters

NameTypeDescription
allOperationsScopesSystem.Collections.Generic.IEnumerable<string>The scopes required for all operations on this entity.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when allOperationsScopes is null.

.ctor

Initializes a new instance of the EntityScopeRequirements class with separate read and write scopes.

Syntax

public EntityScopeRequirements(System.Collections.Generic.IEnumerable<string> readScopes, System.Collections.Generic.IEnumerable<string> writeScopes)

Parameters

NameTypeDescription
readScopesSystem.Collections.Generic.IEnumerable<string>The scopes required for read operations.
writeScopesSystem.Collections.Generic.IEnumerable<string>The scopes required for write operations.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when readScopes or writeScopes is null.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

CreateScopes

Gets or sets the scopes required for creating entities of this type.

Syntax

public System.Collections.Generic.List<string> CreateScopes { get; set; }

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

public System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> CustomOperationScopes { get; set; }

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

public System.Collections.Generic.List<string> DeleteScopes { get; set; }

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. Gets or sets the scopes required for navigating to related entities.

Syntax

public System.Collections.Generic.List<string> NavigateScopes { get; set; }

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

public System.Collections.Generic.List<string> QueryScopes { get; set; }

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

public System.Collections.Generic.List<string> ReadScopes { get; set; }

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

public System.Collections.Generic.List<string> UpdateScopes { get; set; }

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

public void AddCustomOperation(string operationName, System.Collections.Generic.IEnumerable<string> scopes)

Parameters

NameTypeDescription
operationNamestringThe name of the custom operation.
scopesSystem.Collections.Generic.IEnumerable<string>The required scopes for the operation.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when operationName is null or whitespace.
ArgumentNullExceptionThrown when scopes is null.

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetAllScopes

Gets all unique scopes defined for this entity across all operations.

Syntax

public System.Collections.Generic.IEnumerable<string> GetAllScopes()

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of all unique scopes defined for this entity.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetScopesForOperation

Gets the required scopes for a specific operation.

Syntax

public System.Collections.Generic.IEnumerable<string> GetScopesForOperation(string operation)

Parameters

NameTypeDescription
operationstringThe 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 object

Syntax

public System.Type GetType()

Returns

Type: System.Type

HasAnyScopes

Determines whether any scopes are defined for this entity.

Syntax

public bool HasAnyScopes()

Returns

Type: bool true if any scopes are defined; otherwise, false.

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

SetScopesForOperation

Sets the required scopes for a specific operation.

Syntax

public void SetScopesForOperation(string operation, System.Collections.Generic.IEnumerable<string> scopes)

Parameters

NameTypeDescription
operationstringThe operation name.
scopesSystem.Collections.Generic.IEnumerable<string>The required scopes for the operation.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when operation is null or whitespace.
ArgumentNullExceptionThrown when scopes is null.

ToString Override

Returns a string representation of the entity scope requirements.

Syntax

public override string ToString()

Returns

Type: string A summary of the scope requirements for this entity.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the entity scope requirements for consistency and completeness.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate()

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of validation errors, or an empty collection if the requirements are valid.