Esempio n. 1
0
 /*Constructor for use when providing an aad access token to be exchanged for an acr refresh token. Note that token expiration will require manually
  * providing new aad tokens. This model assumes the client is able to do this authentication themselves for AAD tokens. A callback can be provided to
  * be executed once the ACR refresh token expires and can no longer be renewed as the provided Aad Token has expired.*/
 public AcrClientCredentials(string aadAccessToken, string loginUrl, string tenant = null, string LoginUri = null, CancellationToken cancellationToken = default, AuthToken.acquireCallback acquireNewAad = null)
 {
     AcrScopes                = new Dictionary <string, string>();
     AcrAccessTokens          = new Dictionary <string, AcrAccessToken>();
     Mode                     = LoginMode.TokenAad;
     LoginUrl                 = loginUrl;
     RequestCancellationToken = cancellationToken;
     AadAccess                = new AuthToken(aadAccessToken, acquireNewAad);
     AcrRefresh               = new AcrRefreshToken(AadAccess, LoginUrl);
     Tenant                   = tenant;
 }
Esempio n. 2
0
 public AcrAccessToken(AcrRefreshToken acrRefresh, string scope, string loginUrl)
 {
     Scope      = scope;
     authClient = new AzureContainerRegistryClient(new TokenCredentials())
     {
         LoginUri = "https://" + loginUrl
     };
     RefreshFn = () =>
     {
         acrRefresh.CheckAndRefresh();
         return(authClient.GetAccessTokenAsync(loginUrl, scope, acrRefresh.Value).GetAwaiter().GetResult().AccessTokenProperty);
     };
     Refresh();
 }