-
Notifications
You must be signed in to change notification settings - Fork 46
Add Audience as span attribute for AAD/MSA/Common, Fixes #2970888 #2495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
cd68cf6
fbe8a84
7453c3b
7590468
eb048b0
a8096e5
10ef5ec
dc40771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,16 @@ public abstract class AzureActiveDirectoryAudience { | |
| public static final String ALL = "common"; | ||
| public static final String MSA_MEGA_TENANT_ID = "9188040d-6c67-4c5b-b112-36a304b66dad"; | ||
|
|
||
| // The values here are audience values reported in telemetry | ||
| // rather than the values used to send to eSTS. | ||
| public enum AudienceTelemetryConstant { | ||
| MSA_AUDIENCE_FOR_REPORTING, | ||
| COMMON_AUDIENCE_FOR_REPORTING, | ||
| AAD_AUDIENCE_FOR_REPORTING, | ||
| UNKNOWN_AUDIENCE_FOR_REPORTING; | ||
| } | ||
|
||
|
|
||
|
|
||
| public String getCloudUrl() { | ||
| if (mCloudUrl == null) { | ||
| return AzureActiveDirectory.getDefaultCloudUrl(); | ||
|
|
@@ -154,6 +164,32 @@ public void setTenantId(String tenantId) { | |
| mTenantId = tenantId; | ||
| } | ||
|
|
||
| /** | ||
| * Determines the audience type (MSA, Common, AAD, or Unknown) from the given | ||
| * {@link AzureActiveDirectoryAuthority}. | ||
| * | ||
| * @param authority The authority from which the audience is derived. | ||
| * @return The audience type: "MSA", "Common", "AAD", or "Unknown". | ||
| */ | ||
| public static String getAudienceFromAuthority( final AzureActiveDirectoryAuthority authority) { | ||
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (authority == null || StringUtil.isNullOrEmpty(authority.getAudience().getTenantId())) { | ||
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return AudienceTelemetryConstant.UNKNOWN_AUDIENCE_FOR_REPORTING.name(); | ||
| } | ||
|
|
||
| final String audienceToCheck = authority.getAudience().mTenantId.toLowerCase(Locale.ROOT); | ||
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
tanmaymanolkar1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| switch (audienceToCheck) { | ||
| case CONSUMERS: | ||
| case MSA_MEGA_TENANT_ID: | ||
| return AudienceTelemetryConstant.MSA_AUDIENCE_FOR_REPORTING.name(); | ||
| case ALL: | ||
| return AudienceTelemetryConstant.COMMON_AUDIENCE_FOR_REPORTING.name(); | ||
| default: | ||
| return AudienceTelemetryConstant.AAD_AUDIENCE_FOR_REPORTING.name(); | ||
| } | ||
| } | ||
|
|
||
| public static AzureActiveDirectoryAudience getAzureActiveDirectoryAudience(final String cloudUrl, | ||
| final String tenantId) { | ||
| final String methodName = ":getAzureActiveDirectoryAudience"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.