-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmsftidentity.go
More file actions
69 lines (57 loc) · 1.77 KB
/
Copy pathmsftidentity.go
File metadata and controls
69 lines (57 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package handlers
import (
"github.com/google/uuid"
"github.com/samber/lo"
echo "github.com/theopenlane/echox"
)
// msftAssociatedApplications contains the associated azure applications with the domain
type msftAssociatedApplications struct {
AssociatedApplications []application `json:"associatedApplications"`
}
// application contains the application id of a registered application
type application struct {
// ApplicationID is the application of the registered application in Azure
ApplicationID string `json:"applicationId"`
}
// MSFTIdentityWellKnownHandler returns the application ids for associated applications in
// order to populate the msft identity well-known handler
//
// {
// "associatedApplications": [
// {
// "applicationId": "<uuid>"
// }
// ]
// }
func (h *Handler) MSFTIdentityWellKnownHandler(ctx echo.Context) error {
entraAppID := h.IntegrationsConfig.AzureEntraID.ApplicationID
oneDriveAppID := h.IntegrationsConfig.OneDrive.ApplicationID
teamsAppID := h.IntegrationsConfig.MicrosoftTeams.ApplicationID
applications := []application{}
if entraAppID != "" {
if _, err := uuid.Parse(entraAppID); err == nil {
applications = append(applications, application{
ApplicationID: entraAppID,
})
}
}
if oneDriveAppID != "" {
if _, err := uuid.Parse(oneDriveAppID); err == nil {
applications = append(applications, application{
ApplicationID: oneDriveAppID,
})
}
}
if teamsAppID != "" {
if _, err := uuid.Parse(teamsAppID); err == nil {
applications = append(applications, application{
ApplicationID: teamsAppID,
})
}
}
// ensure we do not have duplicate application ids
applications = lo.Uniq(applications)
return h.Success(ctx, msftAssociatedApplications{
AssociatedApplications: applications,
})
}