azuregraph

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 43 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Microsoft Graph

Parity grade: B · SDK hashicorp/terraform-provider-azuread@v3.10.0 · last audited 2026-11-05 (13393e2c2)

Coverage

Metric Value
PARITY entries audited 37 (12 ok, 25 partial)
Feature families 9 (7 ok, 2 partial)
Known gaps 5
Deferred items 0
Resource leaks clean
Known gaps
  • Not implemented: contacts, create-group-in-administrative-unit (POST administrativeUnits/{id}/members), soft delete and restore of administrative units, administrative-unit scoped role assignments through roleManagement (directoryScopeId /administrativeUnits/{id}), applicationTemplates, tokenIssuancePolicies, claimsMappingPolicies, extension attributes, photos, licensing, manager@odata.bind on user create/update (not documented on the user create/update pages; use PUT manager/$ref), $expand for appRoleAssignments, delta $select=manager (the manager@delta annotation shape is not on the user-delta page) and delta queries for resources other than users and groups.
  • Graph permissions are not enforced (no Authorization_RequestDenied for missing Application.ReadWrite.All and similar); requiredResourceAccess and appRoleAssignments are stored but grant nothing, and tokens carry no roles/scp claims.
  • No authorization-code or device-code flow (only grant_type=password signs a user in), so interactive delegated flows still need a hand-built user token. PFX (X509CertAndPassword) keys keep metadata only, so certificates cannot authenticate from a PFX-only credential; passwordCredentials is not in the Update application property table and PATCH of it stays refused.
  • Terraform azuread fixture (application with web redirect URIs and requiredResourceAccess, service principal, application password) applies, replans empty and destroys against the container (test/terraform/azure/azuread_test.go) using metadata_host and the dev client; other azuread resources (groups, users, app role assignments, federated credentials, directory roles) are not exercised.
  • ARM role assignment validation (--azure-arm-validate-principals) does not know system-assigned identities of VMs, web apps and other ARM resources, so it stays opt-in.

More

Documentation

Index

Constants

View Source
const DefaultDomain = "gopherstack.onmicrosoft.com"

DefaultDomain is the tenant's initial, default verified domain.

View Source
const DefaultPort = 10014

DefaultPort is the Microsoft Graph HTTPS listener.

View Source
const DefaultTenantID = "00000000-0000-0000-0000-000000000000"

DefaultTenantID is the dev tenant; it must equal --azure-arm-tenant-id for tokens to validate.

View Source
const MicrosoftGraphAppID = "00000003-0000-0000-c000-000000000000"

MicrosoftGraphAppID is the well-known application ID of the Microsoft Graph resource service principal.

Variables

View Source
var ErrNilAppContext = errors.New("azuregraph: nil app context")

ErrNilAppContext is returned by Provider.Init for a nil AppContext.

Functions

This section is empty.

Types

type APIApplication

type APIApplication struct {
	AcceptMappedClaims          *bool                      `json:"acceptMappedClaims"`
	RequestedAccessTokenVersion *int                       `json:"requestedAccessTokenVersion"`
	KnownClientApplications     []string                   `json:"knownClientApplications"`
	OAuth2PermissionScopes      []PermissionScope          `json:"oauth2PermissionScopes"`
	PreAuthorizedApplications   []PreAuthorizedApplication `json:"preAuthorizedApplications"`
}

APIApplication is the application's api facet.

type AdministrativeUnit

type AdministrativeUnit struct {
	DeletedDateTime               *time.Time `json:"deletedDateTime"`
	IsMemberManagementRestricted  *bool      `json:"isMemberManagementRestricted"`
	Visibility                    *string    `json:"visibility"`
	MembershipType                *string    `json:"membershipType"`
	MembershipRule                *string    `json:"membershipRule"`
	MembershipRuleProcessingState *string    `json:"membershipRuleProcessingState"`
	Description                   *string    `json:"description"`
	ID                            string     `json:"id"`
	DisplayName                   string     `json:"displayName"`
}

AdministrativeUnit is a Microsoft Entra administrative unit.

type AlternativeSecurityID

type AlternativeSecurityID struct {
	IdentityProvider *string `json:"identityProvider"`
	Key              string  `json:"key"`
	Type             int     `json:"type"`
}

AlternativeSecurityID is a device alternativeSecurityId (internal use only in Graph).

type AppRole

type AppRole struct {
	ID                 string   `json:"id"`
	Description        string   `json:"description,omitempty"`
	DisplayName        string   `json:"displayName,omitempty"`
	Origin             string   `json:"origin,omitempty"`
	Value              string   `json:"value,omitempty"`
	AllowedMemberTypes []string `json:"allowedMemberTypes"`
	IsEnabled          bool     `json:"isEnabled"`
}

AppRole is an appRoles entry.

type AppRoleAssignment

type AppRoleAssignment struct {
	CreatedDateTime      time.Time `json:"createdDateTime"`
	ID                   string    `json:"id"`
	AppRoleID            string    `json:"appRoleId"`
	PrincipalID          string    `json:"principalId"`
	PrincipalType        string    `json:"principalType"`
	PrincipalDisplayName string    `json:"principalDisplayName"`
	ResourceID           string    `json:"resourceId"`
	ResourceDisplayName  string    `json:"resourceDisplayName"`
}

AppRoleAssignment grants an app role of a resource service principal to a principal.

type Application

type Application struct {
	CreatedDateTime            time.Time                `json:"createdDateTime"`
	IsDeviceOnlyAuthSupported  *bool                    `json:"isDeviceOnlyAuthSupported"`
	ServiceManagementReference string                   `json:"serviceManagementReference,omitempty"`
	Notes                      string                   `json:"notes,omitempty"`
	ApplicationTemplateID      string                   `json:"applicationTemplateId,omitempty"`
	PublisherDomain            string                   `json:"publisherDomain"`
	SAMLMetadataURL            string                   `json:"samlMetadataUrl,omitempty"`
	DefaultRedirectURI         string                   `json:"defaultRedirectUri,omitempty"`
	AppID                      string                   `json:"appId"`
	TokenEncryptionKeyID       string                   `json:"tokenEncryptionKeyId,omitempty"`
	ID                         string                   `json:"id"`
	GroupMembershipClaims      string                   `json:"groupMembershipClaims,omitempty"`
	SignInAudience             string                   `json:"signInAudience"`
	UniqueName                 string                   `json:"uniqueName,omitempty"`
	DisplayName                string                   `json:"displayName"`
	Description                string                   `json:"description,omitempty"`
	API                        APIApplication           `json:"api"`
	Certification              jsontext.Value           `json:"certification,omitempty"`
	VerifiedPublisher          jsontext.Value           `json:"verifiedPublisher,omitempty"`
	SPA                        RedirectFacet            `json:"spa"`
	DisabledByMicrosoftStatus  jsontext.Value           `json:"disabledByMicrosoftStatus,omitempty"`
	AddIns                     jsontext.Value           `json:"addIns,omitempty"`
	ParentalControlSettings    jsontext.Value           `json:"parentalControlSettings,omitempty"`
	Info                       jsontext.Value           `json:"info,omitempty"`
	OptionalClaims             jsontext.Value           `json:"optionalClaims,omitempty"`
	AuthenticationBehaviors    jsontext.Value           `json:"authenticationBehaviors,omitempty"`
	PublicClient               RedirectFacet            `json:"publicClient"`
	IdentifierURIs             []string                 `json:"identifierUris"`
	Tags                       []string                 `json:"tags"`
	AppRoles                   []AppRole                `json:"appRoles"`
	RequiredResourceAccess     []RequiredResourceAccess `json:"requiredResourceAccess"`
	PasswordCredentials        []PasswordCredential     `json:"passwordCredentials"`
	KeyCredentials             []KeyCredential          `json:"keyCredentials"`
	Web                        WebApplication           `json:"web"`
	IsFallbackPublicClient     bool                     `json:"isFallbackPublicClient"`
	OAuth2RequirePostResponse  bool                     `json:"oauth2RequirePostResponse"`
}

Application is an application registration.

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the in-memory directory shared by the Graph listener and the ARM token endpoint.

func NewBackend

func NewBackend(cfg Settings, opts ...Option) *Backend

NewBackend returns a directory seeded with the Microsoft Graph service principal.

func (*Backend) ActivateDirectoryRole

func (b *Backend) ActivateDirectoryRole(body map[string]jsontext.Value) (map[string]any, error)

ActivateDirectoryRole activates a directory role from a built-in template.

func (*Backend) AddAdministrativeUnitMember

func (b *Backend) AddAdministrativeUnitMember(auID, memberID string) error

AddAdministrativeUnitMember adds a user or group to an administrative unit.

func (*Backend) AddDirectoryRoleMember

func (b *Backend) AddDirectoryRoleMember(ref Ref, memberID string) error

AddDirectoryRoleMember assigns the role to a principal at tenant scope.

func (*Backend) AddKey

func (b *Backend) AddKey(id string, in KeyCredential, proof string) (KeyCredential, error)

AddKey registers a key credential and retains the certificate. When the holder already has a valid certificate the proof JWT must be signed by one of them. Graph documents addKey as unavailable until a first certificate exists; the emulator accepts that first key without proof so the call can bootstrap.

func (*Backend) AddMember

func (b *Backend) AddMember(groupID, memberID string) error

AddMember adds a group member reference.

func (*Backend) AddOwner

func (b *Backend) AddOwner(id, ownerID string) error

AddOwner adds an owner reference.

func (*Backend) AddPassword

func (b *Backend) AddPassword(id string, in PasswordCredential) (PasswordCredential, error)

AddPassword adds a client secret to an application or service principal. The returned credential carries SecretText; it is the only time the secret is available.

func (*Backend) AddScopedRoleMember

func (b *Backend) AddScopedRoleMember(auID string, body map[string]jsontext.Value) (ScopedRoleMembership, error)

AddScopedRoleMember assigns an activated directory role to a user with the administrative unit as scope.

func (*Backend) AdministrativeUnitMembers

func (b *Backend) AdministrativeUnitMembers(auID string) ([]Object, error)

AdministrativeUnitMembers lists the members of an administrative unit.

func (*Backend) AuthenticateAssertion

func (b *Backend) AuthenticateAssertion(clientID, assertion string, audiences []string) (string, bool, error)

AuthenticateAssertion verifies a JWT client assertion for clientID. audiences are the aud values accepted for a certificate assertion (the token endpoint and issuer URLs). known is false for a client the directory does not know. An assertion whose iss and sub are the client ID is a certificate assertion, checked against the stored keyCredentials; any other is matched against the application's federated identity credentials.

func (*Backend) AuthenticateClient

func (b *Backend) AuthenticateClient(clientID, secret string) (string, bool, error)

AuthenticateClient checks a client-credentials request against the registered applications. known is false for a client ID no application or service principal uses, leaving the caller free to apply its own policy. On success objectID is the service principal's object ID, the token's oid claim.

func (*Backend) AuthenticateUser

func (b *Backend) AuthenticateUser(username, password string) (string, string, error)

AuthenticateUser verifies a resource-owner password sign-in and returns the user's object ID and user principal name. Repeated failures lock the account for a minute on the backend clock (Learn: howto-password-smart-lockout defaults); as in Entra, anyone who knows a user's name can trigger that lockout.

func (*Backend) ByIDs

func (b *Backend) ByIDs(ids, types []string) ([]Object, error)

ByIDs resolves object IDs, optionally restricted to kinds ("user", "group", ... or "directoryObject").

func (*Backend) CreateAdministrativeUnit

func (b *Backend) CreateAdministrativeUnit(body map[string]jsontext.Value) (AdministrativeUnit, error)

CreateAdministrativeUnit creates an administrative unit.

func (*Backend) CreateAppRoleAssignment

func (b *Backend) CreateAppRoleAssignment(
	ownerID string, asResource bool, body map[string]jsontext.Value,
) (AppRoleAssignment, error)

CreateAppRoleAssignment grants an app role. ownerID is the path service principal, user or group; asResource selects appRoleAssignedTo (owner is the resource) over appRoleAssignments (owner is the principal).

func (*Backend) CreateApplication

func (b *Backend) CreateApplication(body map[string]jsontext.Value) (Application, error)

CreateApplication registers an application.

func (*Backend) CreateDevice

func (b *Backend) CreateDevice(body map[string]jsontext.Value) (Device, error)

CreateDevice registers a device.

func (*Backend) CreateFederatedCredential

func (b *Backend) CreateFederatedCredential(
	appID string,
	body map[string]jsontext.Value,
) (FederatedCredential, error)

CreateFederatedCredential adds a federated identity credential to an application.

func (*Backend) CreateGrant

func (b *Backend) CreateGrant(body map[string]jsontext.Value) (OAuth2PermissionGrant, error)

CreateGrant records a delegated permission grant.

func (*Backend) CreateGroup

func (b *Backend) CreateGroup(body map[string]jsontext.Value) (Group, error)

CreateGroup creates a group; members@odata.bind and owners@odata.bind add references atomically.

func (*Backend) CreateRoleAssignment

func (b *Backend) CreateRoleAssignment(body map[string]jsontext.Value) (RoleAssignment, error)

CreateRoleAssignment assigns a built-in directory role to a user, role-assignable group or service principal.

func (*Backend) CreateRoleDefinition

func (b *Backend) CreateRoleDefinition(body map[string]jsontext.Value) (RoleDefinition, error)

CreateRoleDefinition creates a custom role definition.

func (*Backend) CreateServicePrincipal

func (b *Backend) CreateServicePrincipal(body map[string]jsontext.Value) (ServicePrincipal, error)

CreateServicePrincipal instantiates an application in the tenant; body.appId must name a registered application.

func (*Backend) CreateUser

func (b *Backend) CreateUser(body map[string]jsontext.Value) (User, error)

CreateUser creates a user; only a salted hash of the passwordProfile password is kept.

func (*Backend) DeleteAdministrativeUnit

func (b *Backend) DeleteAdministrativeUnit(r Ref) error

DeleteAdministrativeUnit removes an administrative unit with its membership and scoped role members.

func (*Backend) DeleteAppRoleAssignment

func (b *Backend) DeleteAppRoleAssignment(id, assignmentID string, asResource bool) error

DeleteAppRoleAssignment removes an assignment owned by id.

func (*Backend) DeleteApplication

func (b *Backend) DeleteApplication(r Ref) error

DeleteApplication soft-deletes an application together with its service principal.

func (*Backend) DeleteDevice

func (b *Backend) DeleteDevice(r Ref) error

DeleteDevice permanently removes a device and its registered owner and user links; Learn lists no soft delete.

func (*Backend) DeleteFederatedCredential

func (b *Backend) DeleteFederatedCredential(appID, key string) error

DeleteFederatedCredential removes a credential.

func (*Backend) DeleteGrant

func (b *Backend) DeleteGrant(id string) error

DeleteGrant removes a grant.

func (*Backend) DeleteGroup

func (b *Backend) DeleteGroup(r Ref) error

DeleteGroup removes a group.

func (*Backend) DeleteRoleAssignment

func (b *Backend) DeleteRoleAssignment(id string) error

DeleteRoleAssignment removes a role assignment.

func (*Backend) DeleteRoleDefinition

func (b *Backend) DeleteRoleDefinition(id string) error

DeleteRoleDefinition soft-deletes a custom role definition that has no assignments.

func (*Backend) DeleteServicePrincipal

func (b *Backend) DeleteServicePrincipal(r Ref) error

DeleteServicePrincipal removes a service principal.

func (*Backend) DeleteUser

func (b *Backend) DeleteUser(r Ref) error

DeleteUser removes a user.

func (*Backend) Delta

func (b *Backend) Delta(q deltaQuery) (DeltaPage, error)

Delta serves one request of a users or groups delta round.

func (*Backend) DirectReports

func (b *Backend) DirectReports(id string) ([]Object, error)

DirectReports lists the users whose manager is the given user.

func (*Backend) DirectoryRoleMembers

func (b *Backend) DirectoryRoleMembers(ref Ref) ([]Object, error)

DirectoryRoleMembers lists the principals holding the role at tenant scope.

func (*Backend) DirectoryRoles

func (b *Backend) DirectoryRoles() []map[string]any

DirectoryRoles lists the activated directory roles.

func (*Backend) GetAdministrativeUnit

func (b *Backend) GetAdministrativeUnit(r Ref) (AdministrativeUnit, error)

GetAdministrativeUnit returns an administrative unit.

func (*Backend) GetApplication

func (b *Backend) GetApplication(r Ref) (Application, error)

GetApplication returns an application.

func (*Backend) GetDeleted

func (b *Backend) GetDeleted(id string) (DeletedObject, error)

GetDeleted returns one soft-deleted object.

func (*Backend) GetDeletedRoleDefinition

func (b *Backend) GetDeletedRoleDefinition(id string) (RoleDefinition, error)

GetDeletedRoleDefinition returns a soft-deleted custom role definition.

func (*Backend) GetDevice

func (b *Backend) GetDevice(r Ref) (Device, error)

GetDevice returns a device by object ID or deviceId.

func (*Backend) GetDirectoryRole

func (b *Backend) GetDirectoryRole(ref Ref) (map[string]any, error)

GetDirectoryRole returns an activated role by ID or roleTemplateId.

func (*Backend) GetFederatedCredential

func (b *Backend) GetFederatedCredential(appID, key string) (FederatedCredential, error)

GetFederatedCredential returns one credential by ID or name.

func (*Backend) GetGroup

func (b *Backend) GetGroup(r Ref) (Group, error)

GetGroup returns a group.

func (*Backend) GetObject

func (b *Backend) GetObject(id string) (Object, error)

GetObject returns any directory object by ID.

func (*Backend) GetRoleAssignment

func (b *Backend) GetRoleAssignment(id string) (RoleAssignment, error)

GetRoleAssignment returns one role assignment.

func (*Backend) GetRoleDefinition

func (b *Backend) GetRoleDefinition(id string) (RoleDefinition, error)

GetRoleDefinition returns one active role definition.

func (*Backend) GetServicePrincipal

func (b *Backend) GetServicePrincipal(r Ref) (ServicePrincipal, error)

GetServicePrincipal returns a service principal.

func (*Backend) GetUser

func (b *Backend) GetUser(r Ref) (User, error)

GetUser returns a user by object ID or user principal name.

func (*Backend) ListAdministrativeUnits

func (b *Backend) ListAdministrativeUnits() []AdministrativeUnit

ListAdministrativeUnits returns every administrative unit in creation order.

func (*Backend) ListAppRoleAssignments

func (b *Backend) ListAppRoleAssignments(id string, asResource bool) ([]AppRoleAssignment, error)

ListAppRoleAssignments lists assignments where id is the principal, or (asResource) the resource.

func (*Backend) ListApplications

func (b *Backend) ListApplications() []Application

ListApplications returns every application in creation order.

func (*Backend) ListDeleted

func (b *Backend) ListDeleted(kind string) []DeletedObject

ListDeleted returns the soft-deleted objects of a kind (all kinds when kind is empty).

func (*Backend) ListDevices

func (b *Backend) ListDevices() []Device

ListDevices returns every device in creation order.

func (*Backend) ListFederatedCredentials

func (b *Backend) ListFederatedCredentials(appID string) ([]FederatedCredential, error)

ListFederatedCredentials lists an application's federated identity credentials.

func (*Backend) ListGrants

func (b *Backend) ListGrants() []OAuth2PermissionGrant

ListGrants returns every delegated permission grant.

func (*Backend) ListGroups

func (b *Backend) ListGroups() []Group

ListGroups returns every group in creation order.

func (*Backend) ListRoleAssignments

func (b *Backend) ListRoleAssignments() []RoleAssignment

ListRoleAssignments returns every directory role assignment.

func (*Backend) ListRoleDefinitions

func (b *Backend) ListRoleDefinitions() []RoleDefinition

ListRoleDefinitions returns the built-in and active custom role definitions.

func (*Backend) ListServicePrincipals

func (b *Backend) ListServicePrincipals() []ServicePrincipal

ListServicePrincipals returns every service principal in creation order.

func (*Backend) ListUsers

func (b *Backend) ListUsers() []User

ListUsers returns every user in creation order.

func (*Backend) Manager

func (b *Backend) Manager(id string) (User, error)

Manager returns the user's manager, or a 404 when none is assigned.

func (*Backend) MemberOf

func (b *Backend) MemberOf(id string, transitive bool) ([]Object, error)

MemberOf lists the groups id belongs to, directly or (transitive) through nesting.

func (*Backend) Members

func (b *Backend) Members(id string) ([]Object, error)

Members lists the direct members of a group.

func (*Backend) ObjectKind

func (b *Backend) ObjectKind(id string) (string, bool)

ObjectKind reports whether id names a directory object and its kind.

func (*Backend) Owners

func (b *Backend) Owners(id string) ([]Object, error)

Owners lists the owners of an application, service principal or group.

func (*Backend) PermanentDelete

func (b *Backend) PermanentDelete(id string) error

PermanentDelete removes a soft-deleted object for good.

func (*Backend) PermanentDeleteRoleDefinition

func (b *Backend) PermanentDeleteRoleDefinition(id string) error

PermanentDeleteRoleDefinition removes a soft-deleted custom role definition for good.

func (*Backend) PrincipalType

func (b *Backend) PrincipalType(id string) (string, bool)

PrincipalType reports whether id is a user, group or service principal and returns its role-assignment principal type (User, Group or ServicePrincipal).

func (*Backend) RemoveAdministrativeUnitMember

func (b *Backend) RemoveAdministrativeUnitMember(auID, memberID string) error

RemoveAdministrativeUnitMember removes a member from an administrative unit.

func (*Backend) RemoveDirectoryRoleMember

func (b *Backend) RemoveDirectoryRoleMember(ref Ref, memberID string) error

RemoveDirectoryRoleMember removes a principal's tenant-scope assignment of the role.

func (*Backend) RemoveKey

func (b *Backend) RemoveKey(id, keyID string) error

RemoveKey deletes a key credential.

func (*Backend) RemoveManager

func (b *Backend) RemoveManager(id string) error

RemoveManager clears the user's manager.

func (*Backend) RemoveMember

func (b *Backend) RemoveMember(groupID, memberID string) error

RemoveMember removes a group member reference.

func (*Backend) RemoveOwner

func (b *Backend) RemoveOwner(id, ownerID string) error

RemoveOwner removes an owner reference.

func (*Backend) RemovePassword

func (b *Backend) RemovePassword(id, keyID string) error

RemovePassword deletes a client secret.

func (*Backend) RemoveScopedRoleMember

func (b *Backend) RemoveScopedRoleMember(auID, id string) error

RemoveScopedRoleMember deletes one scoped role membership.

func (*Backend) Reset

func (b *Backend) Reset()

Reset drops all state and re-seeds the built-in service principals.

func (*Backend) Restore

func (b *Backend) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Backend) RestoreDeleted

func (b *Backend) RestoreDeleted(id string) (Object, error)

RestoreDeleted moves a soft-deleted object back into the directory with its own owners, members, credentials and (for a user) group memberships. References from other objects to it are gone, as are its app role assignments and grants.

func (*Backend) RestoreRoleDefinition

func (b *Backend) RestoreRoleDefinition(id string) (RoleDefinition, error)

RestoreRoleDefinition moves a soft-deleted custom role definition back to the active set.

func (*Backend) ScopedRoleMembers

func (b *Backend) ScopedRoleMembers(auID string) ([]ScopedRoleMembership, error)

ScopedRoleMembers lists the scoped role members of an administrative unit.

func (*Backend) SetIssuerKeys

func (b *Backend) SetIssuerKeys(r KeyResolver)

SetIssuerKeys lets federated identity credential assertions signed by an emulator-run OIDC issuer be verified in-process. Assertions whose kid the resolver does not know are matched by claims only.

func (*Backend) SetManager

func (b *Backend) SetManager(id, managerID string) error

SetManager assigns managerID as the manager of the user; only users can be managers and chains cannot loop.

func (*Backend) Snapshot

func (b *Backend) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable. Secrets are salted PBKDF2 hashes; plaintext is never stored.

func (*Backend) TenantID

func (b *Backend) TenantID() string

TenantID returns the directory's tenant.

func (*Backend) TransitiveMembers

func (b *Backend) TransitiveMembers(id string) ([]Object, error)

TransitiveMembers lists a group's members including those of nested groups.

func (*Backend) UpdateAdministrativeUnit

func (b *Backend) UpdateAdministrativeUnit(r Ref, body map[string]jsontext.Value) error

UpdateAdministrativeUnit applies a PATCH body.

func (*Backend) UpdateApplication

func (b *Backend) UpdateApplication(r Ref, body map[string]jsontext.Value) error

UpdateApplication applies a PATCH body.

func (*Backend) UpdateDevice

func (b *Backend) UpdateDevice(r Ref, body map[string]jsontext.Value) error

UpdateDevice applies a PATCH body; only the properties Learn lists as writable are accepted.

func (*Backend) UpdateFederatedCredential

func (b *Backend) UpdateFederatedCredential(appID, key string, body map[string]jsontext.Value) error

UpdateFederatedCredential patches a credential; its name is immutable.

func (*Backend) UpdateGrant

func (b *Backend) UpdateGrant(id string, body map[string]jsontext.Value) error

UpdateGrant changes the scope of a grant.

func (*Backend) UpdateGroup

func (b *Backend) UpdateGroup(r Ref, body map[string]jsontext.Value) error

UpdateGroup applies a PATCH body. isAssignableToRole can only be set at creation.

func (*Backend) UpdateRoleDefinition

func (b *Backend) UpdateRoleDefinition(id string, body map[string]jsontext.Value) error

UpdateRoleDefinition applies a PATCH body to a custom role definition.

func (*Backend) UpdateServicePrincipal

func (b *Backend) UpdateServicePrincipal(r Ref, body map[string]jsontext.Value) error

UpdateServicePrincipal applies a PATCH body.

func (*Backend) UpdateUser

func (b *Backend) UpdateUser(r Ref, body map[string]jsontext.Value) error

UpdateUser applies a PATCH body.

type ClientAuthError

type ClientAuthError struct {
	Name        string
	Description string
	Status      int
	Code        int
}

ClientAuthError is an Entra token endpoint failure for a client-credentials request.

func (*ClientAuthError) Error

func (e *ClientAuthError) Error() string

type ConfigProvider

type ConfigProvider interface {
	GetAzureGraphSettings() Settings
}

ConfigProvider extracts the Microsoft Graph settings from the AppContext config.

type DeletedObject

type DeletedObject struct {
	DeletedDateTime time.Time
	Object
}

DeletedObject is a soft-deleted directory object.

type DeltaPage

type DeltaPage struct {
	NextToken  string
	DeltaToken string
	Items      []map[string]any
}

DeltaPage is one response of a delta round.

type Device

type Device struct {
	RegistrationDateTime          time.Time               `json:"registrationDateTime"`
	ApproximateLastSignInDateTime *time.Time              `json:"approximateLastSignInDateTime"`
	ComplianceExpirationDateTime  *time.Time              `json:"complianceExpirationDateTime"`
	OnPremisesSyncEnabled         *bool                   `json:"onPremisesSyncEnabled"`
	IsCompliant                   *bool                   `json:"isCompliant"`
	IsManaged                     *bool                   `json:"isManaged"`
	IsRooted                      *bool                   `json:"isRooted"`
	DeviceMetadata                *string                 `json:"deviceMetadata"`
	DeviceVersion                 *int                    `json:"deviceVersion"`
	ID                            string                  `json:"id"`
	DeviceID                      string                  `json:"deviceId"`
	DisplayName                   string                  `json:"displayName"`
	DeviceCategory                string                  `json:"deviceCategory,omitempty"`
	DeviceOwnership               string                  `json:"deviceOwnership,omitempty"`
	EnrollmentProfileName         string                  `json:"enrollmentProfileName,omitempty"`
	EnrollmentType                string                  `json:"enrollmentType,omitempty"`
	ManagementType                string                  `json:"managementType,omitempty"`
	Manufacturer                  string                  `json:"manufacturer,omitempty"`
	MDMAppID                      string                  `json:"mdmAppId,omitempty"`
	Model                         string                  `json:"model,omitempty"`
	OperatingSystem               string                  `json:"operatingSystem"`
	OperatingSystemVersion        string                  `json:"operatingSystemVersion"`
	ProfileType                   string                  `json:"profileType,omitempty"`
	TrustType                     string                  `json:"trustType,omitempty"`
	AlternativeSecurityIDs        []AlternativeSecurityID `json:"alternativeSecurityIds"`
	PhysicalIDs                   []string                `json:"physicalIds"`
	SystemLabels                  []string                `json:"systemLabels"`
	AccountEnabled                bool                    `json:"accountEnabled"`
}

Device is a registered or joined device.

type Error

type Error struct {
	Code    string
	Message string
	Status  int
}

Error is a Graph failure rendered as an OData error envelope.

func (*Error) Error

func (e *Error) Error() string

type FederatedCredential

type FederatedCredential struct {
	Description *string  `json:"description"`
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Issuer      string   `json:"issuer"`
	Subject     string   `json:"subject"`
	Audiences   []string `json:"audiences"`
}

FederatedCredential is an application's federatedIdentityCredential.

type Group

type Group struct {
	CreatedDateTime               time.Time `json:"createdDateTime"`
	IsAssignableToRole            *bool     `json:"isAssignableToRole"`
	MembershipRule                string    `json:"membershipRule,omitempty"`
	MembershipRuleProcessingState string    `json:"membershipRuleProcessingState,omitempty"`
	MailNickname                  string    `json:"mailNickname"`
	Mail                          string    `json:"mail,omitempty"`
	Visibility                    string    `json:"visibility,omitempty"`
	Classification                string    `json:"classification,omitempty"`
	DisplayName                   string    `json:"displayName"`
	Description                   string    `json:"description,omitempty"`
	PreferredDataLocation         string    `json:"preferredDataLocation,omitempty"`
	ID                            string    `json:"id"`
	ResourceBehaviorOptions       []string  `json:"resourceBehaviorOptions"`
	ResourceProvisioningOptions   []string  `json:"resourceProvisioningOptions"`
	GroupTypes                    []string  `json:"groupTypes"`
	MailEnabled                   bool      `json:"mailEnabled"`
	SecurityEnabled               bool      `json:"securityEnabled"`
}

Group is a security, Microsoft 365 or distribution group.

type Handler

type Handler struct {
	Backend *Backend
	// Issuer verifies bearer tokens when Settings.ValidateTokens is set; cli wiring shares ARM's issuer.
	Issuer *aadauth.Issuer

	// Settings holds the listener configuration.
	Settings Settings
	// Port is the fixed TCP port StartWorker binds.
	Port int
	// contains filtered or unexported fields
}

Handler serves Microsoft Graph v1.0 directory APIs on a dedicated HTTPS listener.

func NewHandler

func NewHandler(backend *Backend, settings Settings) *Handler

NewHandler creates a Handler.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation names the operation for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the request path for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the operation names ExtractOperation can return.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler for the Graph API.

func (*Handler) InProcessToken

func (h *Handler) InProcessToken() (string, error)

InProcessToken mints a short-lived bearer token this handler accepts, for callers in the same process that never see the listener. The token has no oid, so objects created with it get no owner.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Microsoft Graph runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the fixed port and serves HTTPS, failing fast if the port is taken.

type ImplicitGrantSettings

type ImplicitGrantSettings struct {
	EnableAccessTokenIssuance bool `json:"enableAccessTokenIssuance"`
	EnableIDTokenIssuance     bool `json:"enableIdTokenIssuance"`
}

ImplicitGrantSettings is web.implicitGrantSettings.

type KeyCredential

type KeyCredential struct {
	StartDateTime       time.Time `json:"startDateTime"`
	EndDateTime         time.Time `json:"endDateTime"`
	Key                 *string   `json:"key"`
	CustomKeyIdentifier *string   `json:"customKeyIdentifier"`
	DisplayName         *string   `json:"displayName"`
	KeyID               string    `json:"keyId"`
	Type                string    `json:"type"`
	Usage               string    `json:"usage"`
}

KeyCredential is a certificate or key credential; the key material is never returned.

type KeyResolver

type KeyResolver func(kid string) (crypto.PublicKey, bool)

KeyResolver returns the public key of an emulator-run OIDC issuer for a JWT key ID.

type OAuth2PermissionGrant

type OAuth2PermissionGrant struct {
	ID          string `json:"id"`
	ClientID    string `json:"clientId"`
	ConsentType string `json:"consentType"`
	PrincipalID string `json:"principalId,omitempty"`
	ResourceID  string `json:"resourceId"`
	Scope       string `json:"scope"`
}

OAuth2PermissionGrant is a delegated permission grant.

type Object

type Object struct {
	Entity any
	Kind   string
}

Object is a directory object of any kind with its entity (Application, ServicePrincipal, User or Group).

type Option

type Option func(*Backend)

Option customises a Backend.

func WithClock

func WithClock(now func() time.Time) Option

WithClock replaces the wall clock.

type PasswordCredential

type PasswordCredential struct {
	StartDateTime       time.Time `json:"startDateTime"`
	EndDateTime         time.Time `json:"endDateTime"`
	SecretText          *string   `json:"secretText"`
	CustomKeyIdentifier *string   `json:"customKeyIdentifier"`
	DisplayName         *string   `json:"displayName"`
	Hint                *string   `json:"hint"`
	KeyID               string    `json:"keyId"`
}

PasswordCredential is a client secret; SecretText is only set in the addPassword response.

type PasswordProfile

type PasswordProfile struct {
	Password                      string `json:"password"`
	ForceChangePasswordNextSignIn bool   `json:"forceChangePasswordNextSignIn"`
	ForceChangePasswordNextMFA    bool   `json:"forceChangePasswordNextSignInWithMfa"`
}

PasswordProfile is accepted on write and never returned.

type PermissionScope

type PermissionScope struct {
	ID                      string `json:"id"`
	AdminConsentDescription string `json:"adminConsentDescription,omitempty"`
	AdminConsentDisplayName string `json:"adminConsentDisplayName,omitempty"`
	Type                    string `json:"type,omitempty"`
	UserConsentDescription  string `json:"userConsentDescription,omitempty"`
	UserConsentDisplayName  string `json:"userConsentDisplayName,omitempty"`
	Value                   string `json:"value,omitempty"`
	IsEnabled               bool   `json:"isEnabled"`
}

PermissionScope is an api.oauth2PermissionScopes entry.

type PreAuthorizedApplication

type PreAuthorizedApplication struct {
	AppID                  string   `json:"appId"`
	DelegatedPermissionIDs []string `json:"delegatedPermissionIds"`
}

PreAuthorizedApplication is an api.preAuthorizedApplications entry.

type Provider

type Provider struct{}

Provider implements service.Provider for Microsoft Graph.

func (*Provider) Init

Init builds the backend and handler; the port is bound by Handler.StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type RedirectFacet

type RedirectFacet struct {
	RedirectURIs []string `json:"redirectUris"`
}

RedirectFacet carries redirectUris for the spa and publicClient facets.

type Ref

type Ref struct {
	ID    string
	Field string
	Value string
}

Ref addresses an object by ID or by an alternate key such as applications(appId='...').

type RequiredResourceAccess

type RequiredResourceAccess struct {
	ResourceAppID  string           `json:"resourceAppId"`
	ResourceAccess []ResourceAccess `json:"resourceAccess"`
}

RequiredResourceAccess declares the permissions an application needs from one resource.

type ResourceAccess

type ResourceAccess struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

ResourceAccess is a requiredResourceAccess.resourceAccess entry.

type RoleAssignment

type RoleAssignment struct {
	AppScopeID       *string `json:"appScopeId"`
	Condition        *string `json:"condition"`
	ID               string  `json:"id"`
	PrincipalID      string  `json:"principalId"`
	RoleDefinitionID string  `json:"roleDefinitionId"`
	DirectoryScopeID string  `json:"directoryScopeId"`
}

RoleAssignment is a unifiedRoleAssignment of the Entra directory role management API.

type RoleDefinition

type RoleDefinition struct {
	DeletedDateTime *time.Time       `json:"deletedDateTime"`
	Version         *string          `json:"version"`
	ID              string           `json:"id"`
	TemplateID      string           `json:"templateId"`
	DisplayName     string           `json:"displayName"`
	Description     string           `json:"description"`
	ResourceScopes  []string         `json:"resourceScopes"`
	RolePermissions []RolePermission `json:"rolePermissions"`
	IsBuiltIn       bool             `json:"isBuiltIn"`
	IsEnabled       bool             `json:"isEnabled"`
}

RoleDefinition is a unifiedRoleDefinition; built-in roles are derived from the template catalog.

type RoleMemberInfo

type RoleMemberInfo struct {
	ID                string `json:"id"`
	DisplayName       string `json:"displayName"`
	UserPrincipalName string `json:"userPrincipalName"`
}

RoleMemberInfo identifies the principal of a scopedRoleMembership.

type RolePermission

type RolePermission struct {
	Condition              *string  `json:"condition"`
	AllowedResourceActions []string `json:"allowedResourceActions"`
}

RolePermission is a unifiedRolePermission.

type ScopedRoleMembership

type ScopedRoleMembership struct {
	RoleMemberInfo       RoleMemberInfo `json:"roleMemberInfo"`
	ID                   string         `json:"id"`
	AdministrativeUnitID string         `json:"administrativeUnitId"`
	RoleID               string         `json:"roleId"`
}

ScopedRoleMembership assigns a directory role to a user within one administrative unit.

type ServicePrincipal

type ServicePrincipal struct {
	AddIns                        jsontext.Value       `json:"addIns,omitempty"`
	DisabledByMicrosoftStatus     jsontext.Value       `json:"disabledByMicrosoftStatus,omitempty"`
	ResourceSpecificPermissions   jsontext.Value       `json:"resourceSpecificApplicationPermissions,omitempty"`
	PasswordSSOSettings           jsontext.Value       `json:"passwordSingleSignOnSettings,omitempty"`
	PreferredKeyEndDateTime       jsontext.Value       `json:"preferredTokenSigningKeyEndDateTime,omitempty"`
	CustomSecurityAttributes      jsontext.Value       `json:"customSecurityAttributes,omitempty"`
	SAMLMetadataURL               string               `json:"samlMetadataUrl,omitempty"`
	ApplicationTemplateID         string               `json:"applicationTemplateId,omitempty"`
	CreatedDateTime               time.Time            `json:"createdDateTime"`
	Info                          jsontext.Value       `json:"info,omitempty"`
	VerifiedPublisher             jsontext.Value       `json:"verifiedPublisher,omitempty"`
	SAMLSingleSignOnSettings      jsontext.Value       `json:"samlSingleSignOnSettings,omitempty"`
	ID                            string               `json:"id"`
	AppID                         string               `json:"appId"`
	DisplayName                   string               `json:"displayName"`
	AppDisplayName                string               `json:"appDisplayName"`
	AppDescription                string               `json:"appDescription,omitempty"`
	AppOwnerOrganizationID        string               `json:"appOwnerOrganizationId,omitempty"`
	Description                   string               `json:"description,omitempty"`
	LoginURL                      string               `json:"loginUrl,omitempty"`
	LogoutURL                     string               `json:"logoutUrl,omitempty"`
	Homepage                      string               `json:"homepage,omitempty"`
	Notes                         string               `json:"notes,omitempty"`
	PreferredSingleSignOnMode     string               `json:"preferredSingleSignOnMode,omitempty"`
	PreferredTokenSigningKeyThumb string               `json:"preferredTokenSigningKeyThumbprint,omitempty"`
	ServicePrincipalType          string               `json:"servicePrincipalType"`
	SignInAudience                string               `json:"signInAudience"`
	TokenEncryptionKeyID          string               `json:"tokenEncryptionKeyId,omitempty"`
	AlternativeNames              []string             `json:"alternativeNames"`
	NotificationEmailAddresses    []string             `json:"notificationEmailAddresses"`
	ReplyURLs                     []string             `json:"replyUrls"`
	ServicePrincipalNames         []string             `json:"servicePrincipalNames"`
	Tags                          []string             `json:"tags"`
	AppRoles                      []AppRole            `json:"appRoles"`
	OAuth2PermissionScopes        []PermissionScope    `json:"oauth2PermissionScopes"`
	PasswordCredentials           []PasswordCredential `json:"passwordCredentials"`
	KeyCredentials                []KeyCredential      `json:"keyCredentials"`
	AccountEnabled                bool                 `json:"accountEnabled"`
	AppRoleAssignmentRequired     bool                 `json:"appRoleAssignmentRequired"`
}

ServicePrincipal is the local instance of an application in the tenant.

type Settings

type Settings struct {
	TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 241-byte string literal not displayed */
	TLSKeyFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 138-byte string literal not displayed */
	TenantID string `` //nolint:lll // config struct tags are intentionally verbose
	/* 288-byte string literal not displayed */
	DefaultDomain string `` //nolint:lll // config struct tags are intentionally verbose
	/* 279-byte string literal not displayed */
	DevClientID string `` //nolint:lll // config struct tags are intentionally verbose
	/* 288-byte string literal not displayed */
	ExtraDomains string `` //nolint:lll // config struct tags are intentionally verbose
	/* 130-byte string literal not displayed */
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 257-byte string literal not displayed */
	ValidateTokens bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 257-byte string literal not displayed */
}

Settings is the Kong-embedded configuration of the Microsoft Graph emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider exists.

type User

type User struct {
	CreatedDateTime   time.Time        `json:"createdDateTime"`
	PasswordProfile   *PasswordProfile `json:"passwordProfile,omitempty"`
	ID                string           `json:"id"`
	UserPrincipalName string           `json:"userPrincipalName"`
	DisplayName       string           `json:"displayName"`
	MailNickname      string           `json:"mailNickname"`
	GivenName         string           `json:"givenName,omitempty"`
	Surname           string           `json:"surname,omitempty"`
	Mail              string           `json:"mail,omitempty"`
	JobTitle          string           `json:"jobTitle,omitempty"`
	Department        string           `json:"department,omitempty"`
	CompanyName       string           `json:"companyName,omitempty"`
	OfficeLocation    string           `json:"officeLocation,omitempty"`
	City              string           `json:"city,omitempty"`
	State             string           `json:"state,omitempty"`
	Country           string           `json:"country,omitempty"`
	StreetAddress     string           `json:"streetAddress,omitempty"`
	PostalCode        string           `json:"postalCode,omitempty"`
	MobilePhone       string           `json:"mobilePhone,omitempty"`
	PreferredLanguage string           `json:"preferredLanguage,omitempty"`
	UsageLocation     string           `json:"usageLocation,omitempty"`
	EmployeeID        string           `json:"employeeId,omitempty"`
	PasswordPolicies  string           `json:"passwordPolicies,omitempty"`
	OnPremImmutableID string           `json:"onPremisesImmutableId,omitempty"`
	UserType          string           `json:"userType"`
	BusinessPhones    []string         `json:"businessPhones"`
	OtherMails        []string         `json:"otherMails"`
	AccountEnabled    bool             `json:"accountEnabled"`
}

User is a directory user.

type WebApplication

type WebApplication struct {
	HomePageURL           string                `json:"homePageUrl"`
	LogoutURL             string                `json:"logoutUrl"`
	RedirectURIs          []string              `json:"redirectUris"`
	ImplicitGrantSettings ImplicitGrantSettings `json:"implicitGrantSettings"`
}

WebApplication is the application's web facet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL