mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 18:07:17 +02:00
directory/azure: add paging support to user group members call (#2311)
This commit is contained in:
parent
fcb33966e2
commit
b1d7a126ab
4 changed files with 115 additions and 51 deletions
45
internal/directory/azure/api.go
Normal file
45
internal/directory/azure/api.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package azure
|
||||
|
||||
import "strings"
|
||||
|
||||
type (
|
||||
apiGetUserResponse struct {
|
||||
apiUser
|
||||
}
|
||||
apiGetUserMembersResponse struct {
|
||||
Context string `json:"@odata.context"`
|
||||
NextLink string `json:"@odata.nextLink,omitempty"`
|
||||
Value []apiGroup `json:"value"`
|
||||
}
|
||||
|
||||
apiGroup struct {
|
||||
ID string `json:"id"`
|
||||
DisplayName string `json:"displayName"`
|
||||
}
|
||||
apiUser struct {
|
||||
ID string `json:"id"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Mail string `json:"mail"`
|
||||
UserPrincipalName string `json:"userPrincipalName"`
|
||||
}
|
||||
)
|
||||
|
||||
func (obj apiUser) getEmail() string {
|
||||
if obj.Mail != "" {
|
||||
return obj.Mail
|
||||
}
|
||||
|
||||
// AD often doesn't have the email address returned, but we can parse it from the UPN
|
||||
|
||||
// UPN looks like:
|
||||
// cdoxsey_pomerium.com#EXT#@cdoxseypomerium.onmicrosoft.com
|
||||
email := obj.UserPrincipalName
|
||||
if idx := strings.Index(email, "#EXT"); idx > 0 {
|
||||
email = email[:idx]
|
||||
}
|
||||
// find the last _ and replace it with @
|
||||
if idx := strings.LastIndex(email, "_"); idx > 0 {
|
||||
email = email[:idx] + "@" + email[idx+1:]
|
||||
}
|
||||
return email
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue