-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
directory/azure: add paging support to user group members call (#2311) (
#2312) Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
- Loading branch information
1 parent
88e1458
commit e5d4c82
Showing
4 changed files
with
115 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters