Skip to content

Imdsv2: Generate CSR and execute CSR request #5427

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

Open
wants to merge 21 commits into
base: rginsburg/msiv2_feature_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if SUPPORTS_SYSTEM_TEXT_JSON
using JsonProperty = System.Text.Json.Serialization.JsonPropertyNameAttribute;
#else
using Microsoft.Identity.Client.Utils;
using Microsoft.Identity.Json;
#endif

namespace Microsoft.Identity.Client.ManagedIdentity
{
/// <summary>
/// Represents the response for a Managed Identity CSR request.
/// </summary>
internal class ClientCredentialRequestResponse
{
[JsonProperty("client_id")]
public string ClientId { get; set; }

[JsonProperty("tenant_id")]
public string TenantId { get; set; }

[JsonProperty("client_credential")]
public string ClientCredential { get; set; }

[JsonProperty("regional_token_url")]
public string RegionalTokenUrl { get; set; }

[JsonProperty("expires_in")]
public int ExpiresIn { get; set; }

[JsonProperty("refresh_in")]
public int RefreshIn { get; set; }

public ClientCredentialRequestResponse() { }

public static bool IsValid(ClientCredentialRequestResponse clientCredentialRequestResponse)
{
if (string.IsNullOrEmpty(clientCredentialRequestResponse.ClientId) ||
string.IsNullOrEmpty(clientCredentialRequestResponse.TenantId) ||
string.IsNullOrEmpty(clientCredentialRequestResponse.ClientCredential) ||
string.IsNullOrEmpty(clientCredentialRequestResponse.RegionalTokenUrl) ||
clientCredentialRequestResponse.ExpiresIn <= 0 ||
clientCredentialRequestResponse.RefreshIn <= 0)
{
return false;
}

return true;
}
}
}
Loading