azure_graph_users resource
Use the azure_graph_users
InSpec audit resource to test the properties of some or all Azure Active Directory users within a Tenant.
Azure REST API version, endpoint, and HTTP client parameters
This resource interacts with API versions supported by the resource provider.
You can specify the api_version
as a resource parameter to use a specific version of the Azure REST API.
If you don’t specify an API version, this resource uses the latest version available.
For more information about API versioning, see the azure_generic_resource
.
By default, this resource uses the azure_cloud
global endpoint and default HTTP client settings.
You can override these settings if you need to connect to a different Azure environment (such as Azure Government or Azure China).
For more information about configuration options, see the resource pack README.
Syntax
An azure_graph_users
resource block returns all Azure Active Directory user accounts within the configured Tenant and then tests that group of users.
describe azure_graph_users do
#...
end
Parameters
The following parameters can be passed for targeting specific users.
filter
- A hash containing the filtering options and their values. The
starts_with_
operator can be used for fuzzy string matching. Parameter names are in the snake case.For example,
{ starts_with_given_name: 'J', starts_with_department: 'Core', country: 'United Kingdom', given_name: John}
filter_free_text
- OData query string in double quotes,
"
. Property names are in the camel case. See the Microsoft query parameters documentation for more information.For example,
"startswith(displayName,'J') and surname eq 'Doe'"
or"userType eq 'Guest'"
It is advised to use these parameters to narrow down the targeted resources at the server side, Azure Graph API, for a more efficient test.
Properties
ids
- The unique identifiers of users.
Field:
id
object_ids
- The unique identifiers of users. This is for backward compatibility. Use
ids
instead.Field:
id
display_names
- The display names of users.
Field:
displayName
given_names
- The given names of users.
Field:
givenName
job_titles
- The job titles of users.
Field:
jobTitle
mails
- The email addresses of users.
Field:
mail
user_types
- The user types of users. For example,
Member
,Guest
.Field:
userType
user_principal_names
- The user principal names of users. For example,
jdoe@contoso.com
.Field:
userPrincipalName
Note
Examples
The following examples show how to use this InSpec audit resource.
Check users with some filtering parameters applied at server side (Using ‘filter’):
describe azure_graph_users(filter: {given_name: 'John', starts_with_department: 'Customer'}) do
it { should exist }
end
Check users with some filtering parameters applied at server side (Using ‘filter_free_text’):
describe azure_graph_users(filter_free_text: "startswith(givenName,'J') and startswith(department,'customer') and country eq 'United States'") do
it { should exist }
end
Ensure there are no guest accounts active (client-side filtering):
describe azure_graph_users.guest_accounts do
it { should_not exist }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
exists
The control passes if the filter returns at least one result. Use should_not
if you expect zero matches.
describe azure_graph_users do
it { should exist }
end
Azure permissions
Graph resources require specific privileges granted to your service principal. Please refer to the Microsoft Documentation for information on how to grant these permissions to your application.