Skip to content

Commit 9b1e3be

Browse files
author
Igor Komlew
authored
Added support for user authentication method states for ms365 (#5661)
1 parent 2e7a17e commit 9b1e3be

4 files changed

Lines changed: 122 additions & 0 deletions

File tree

providers/ms365/resources/ms365.lr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ private microsoft.user @defaults("id displayName userPrincipalName") {
377377
auditlog() microsoft.user.auditlog
378378
// The licenses that are assigned to the user, including inherited (group-based) licenses
379379
assignedLicenses []microsoft.user.assignedLicense
380+
// Authentication requirements information
381+
authenticationRequirements() microsoft.user.authenticationRequirements
382+
}
383+
384+
// Microsoft user authentication method states
385+
private microsoft.user.authenticationRequirements {
386+
// user's MFA state
387+
perUserMfaState string
380388
}
381389

382390
// Microsoft user audit log

providers/ms365/resources/ms365.lr.go

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/ms365/resources/ms365.lr.manifest.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ resources:
496496
assignedLicenses: {}
497497
auditlog: {}
498498
authMethods: {}
499+
authenticationRequirements: {}
499500
city: {}
500501
companyName: {}
501502
contact: {}
@@ -551,6 +552,11 @@ resources:
551552
windowsHelloMethods: {}
552553
is_private: true
553554
min_mondoo_version: 9.0.0
555+
microsoft.user.authenticationRequirements:
556+
fields:
557+
perUserMfaState: {}
558+
is_private: true
559+
min_mondoo_version: 9.0.0
554560
microsoft.user.identity:
555561
fields:
556562
issuer: {}

providers/ms365/resources/users.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,28 @@ func newMqlMicrosoftUserAuthentication(runtime *plugin.Runtime, u userAuthentica
811811
}
812812
return graphUser.(*mqlMicrosoftUserAuthenticationMethods), nil
813813
}
814+
815+
func (a *mqlMicrosoftUser) authenticationRequirements() (*mqlMicrosoftUserAuthenticationRequirements, error) {
816+
conn := a.MqlRuntime.Connection.(*connection.Ms365Connection)
817+
graphClient, err := conn.BetaGraphClient()
818+
if err != nil {
819+
return nil, err
820+
}
821+
822+
userID := a.Id.Data
823+
824+
authRequirements, err := graphClient.Users().ByUserId(userID).Authentication().Requirements().Get(context.Background(), nil)
825+
if err != nil {
826+
return nil, transformError(err)
827+
}
828+
829+
mqlAuthRequirements, err := CreateResource(a.MqlRuntime, "microsoft.user.authenticationRequirements",
830+
map[string]*llx.RawData{
831+
"perUserMfaState": llx.StringData(authRequirements.GetPerUserMfaState().String()),
832+
})
833+
if err != nil {
834+
return nil, err
835+
}
836+
837+
return mqlAuthRequirements.(*mqlMicrosoftUserAuthenticationRequirements), nil
838+
}

0 commit comments

Comments
 (0)