public static string GetPresignedUrl(GetPresignedUrlRequest request, IAwsCredential credential, DateTime now) { HttpMethod method = request.Method.Equals("GET") ? HttpMethod.Get : new HttpMethod(request.Method); // TODO: support version querystring return(SignerV4.GetPresignedUrl( credential: credential, scope: new CredentialScope(now, request.Region, AwsService.S3), date: now, expires: request.ExpiresIn, method: method, requestUri: new Uri(request.GetUrl()), payloadHash: UnsignedPayload )); }
public async Task <AuthenticationToken> GetAuthenticationTokenAsync(GetAuthenticationTokenRequest request) { // Ensure the underlying credential is renewed if (credential.ShouldRenew) { await credential.RenewAsync().ConfigureAwait(false); } var date = DateTime.UtcNow; var scope = new CredentialScope(date, region, AwsService.RdsDb); Uri requestUri = new Uri($"https://{request.HostName}:{request.Port}?Action=connect&DBUser={request.UserName}"); Uri url = new Uri(SignerV4.GetPresignedUrl(credential, scope, date, request.Expires, HttpMethod.Get, requestUri)); return(new AuthenticationToken( value: url.Host + ":" + url.Port.ToString() + "/" + url.Query, issued: date, expires: date + request.Expires )); }