turbot/steampipe-mod-microsoft365-compliance

Query: azuread_conditional_access_block_device_code_flow

Usage

powerpipe query microsoft365_compliance.query.azuread_conditional_access_block_device_code_flow

SQL

with tenant_list as (
select distinct on (tenant_id) tenant_id, _ctx
from azuread_user
),
conditional_access_policy as (
select
tenant_id,
count(*) as conditional_access_policy_count
from
azuread_conditional_access_policy
where
users -> 'includeUsers' ? 'All'
and applications -> 'includeApplications' ? 'All'
and built_in_controls @> '[0]'::jsonb
and additional_data -> 'authenticationFlows' ->> 'transferMethods' = 'deviceCodeFlow'
and state = 'enabled'
group
by tenant_id
)
select
t.tenant_id as resource,
case
when conditional_access_policy_count > 0 then 'ok'
else 'alarm'
end as status,
case
when conditional_access_policy_count > 0 then t.tenant_id || ' has a conditional access policy that blocks the device code sign-in flow.'
else t.tenant_id || ' does not have a conditional access policy that blocks the device code sign-in flow.'
end as reason
, t.tenant_id as tenant_id
from
tenant_list as t
left join conditional_access_policy as p on p.tenant_id = t.tenant_id;

Controls

The query is being used by the following controls: