Skip to content

Commit

Permalink
initial pr and kerberos changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rajanadar committed Jan 4, 2021
1 parent 92e85fa commit 29fff56
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 44 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.6.0.2 (Jan 3, 2021)

**IMPROVEMENTS:**

* [Kerberos Auth]: Set pre-authenticate flag to optimize on dual calls.
* [Kerberos Auth]: Use `DefaultCredentials` instead of `DefaultNetworkCredentials` as the default credentials.
* [GH-172]: Add support to query the details of a token
* [GH-172]: Add Transit operations to CRUD encryption keys

## 1.6.0.1 (Dec 6, 2020)

**BREAKING CHANGES:**
Expand Down
1 change: 1 addition & 0 deletions src/VaultSharp/Core/Polymath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public Polymath(VaultClientSettings vaultClientSettings)
if (vaultClientSettings.AuthMethodInfo?.AuthMethodType == AuthMethodType.Kerberos)
{
var kerberosAuthMethodInfo = vaultClientSettings.AuthMethodInfo as KerberosAuthMethodInfo;
handler.PreAuthenticate = kerberosAuthMethodInfo.PreAuthenticate;
handler.Credentials = kerberosAuthMethodInfo.Credentials;
}

Expand Down
32 changes: 26 additions & 6 deletions src/VaultSharp/V1/AuthMethods/Kerberos/KerberosAuthMethodInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Net;
using VaultSharp.Core;

namespace VaultSharp.V1.AuthMethods.Kerberos
Expand Down Expand Up @@ -36,17 +33,28 @@ public class KerberosAuthMethodInfo : AbstractAuthMethodInfo
/// </value>
public ICredentials Credentials { get; }

/// <summary>
/// Flag to indicate if the credentials should be cached.
/// Defaults to true.
/// </summary>
/// <value>
/// The flag.
/// </value>
public bool PreAuthenticate { get; }

/// <summary>
/// Initializes a new instance of the <see cref="KerberosAuthMethodInfo"/> class.
/// </summary>
public KerberosAuthMethodInfo() : this(AuthMethodType.Kerberos.Type, CredentialCache.DefaultNetworkCredentials)
public KerberosAuthMethodInfo()
: this(AuthMethodType.Kerberos.Type, CredentialCache.DefaultCredentials, true)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="KerberosAuthMethodInfo"/> class.
/// </summary>
public KerberosAuthMethodInfo(ICredentials credentials) : this(AuthMethodType.Kerberos.Type, credentials)
public KerberosAuthMethodInfo(ICredentials credentials)
: this(AuthMethodType.Kerberos.Type, credentials, true)
{
}

Expand All @@ -56,12 +64,24 @@ public KerberosAuthMethodInfo(ICredentials credentials) : this(AuthMethodType.Ke
/// <param name="mountPoint">The mount point.</param>
/// <param name="credentials">The credential to use.</param>
public KerberosAuthMethodInfo(string mountPoint, ICredentials credentials)
: this (mountPoint, credentials, true)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="KerberosAuthMethodInfo"/> class.
/// </summary>
/// <param name="mountPoint">The mount point.</param>
/// <param name="credentials">The credential to use.</param>
/// <param name="preAuthenticate">The flag to cache credentials.</param>
public KerberosAuthMethodInfo(string mountPoint, ICredentials credentials, bool preAuthenticate)
{
Checker.NotNull(mountPoint, nameof(mountPoint));
Checker.NotNull(credentials, nameof(credentials));

MountPoint = mountPoint;
Credentials = credentials;
PreAuthenticate = preAuthenticate;
}
}
}
4 changes: 2 additions & 2 deletions src/VaultSharp/V1/AuthMethods/Token/ITokenAuthMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public interface ITokenAuthMethod
/// <summary>
/// Gets token information about the specified token.
/// </summary>
/// <param name="vaultToken">The vault token to lookup</param>
/// <param name="clientToken">The vault token to lookup</param>
/// <returns>
/// The secret with <see cref="TokenInfo" />.
/// </returns>
Task<Secret<TokenInfo>> LookupAsync(string vaultToken);
Task<Secret<ClientTokenInfo>> LookupAsync(string clientToken);

/// <summary>
/// Gets the calling client token information. i.e. the token used by the client as part of this call.
Expand Down
31 changes: 2 additions & 29 deletions src/VaultSharp/V1/AuthMethods/Token/Models/CallingTokenInfo.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
using Newtonsoft.Json;


namespace VaultSharp.V1.AuthMethods.Token.Models
{
/// <summary>
/// Represents the information associated with the calling token.
/// </summary>
public class CallingTokenInfo : TokenAccessorInfo
public class CallingTokenInfo : ClientTokenInfo
{
/// <summary>
/// Gets or sets the accessor.
/// </summary>
/// <value>
/// The accessor.
/// </value>
[JsonProperty("accessor")]
public string Accessor { get; set; }

/// <summary>
/// Gets or sets the explicit maximum time to live.
/// </summary>
/// <value>
/// The explicit maximum time to live.
/// </value>
[JsonProperty("explicit_max_ttl")]
public int ExplicitMaximumTimeToLive { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="CallingTokenInfo"/> is renewable.
/// </summary>
/// <value>
/// <c>true</c> if renewable; otherwise, <c>false</c>.
/// </value>
[JsonProperty("renewable")]
public bool Renewable { get; set; }
}
}
37 changes: 37 additions & 0 deletions src/VaultSharp/V1/AuthMethods/Token/Models/ClientTokenInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Newtonsoft.Json;

namespace VaultSharp.V1.AuthMethods.Token.Models
{
/// <summary>
/// Represents the information associated with the client token.
/// </summary>
public class ClientTokenInfo : TokenAccessorInfo
{
/// <summary>
/// Gets or sets the accessor.
/// </summary>
/// <value>
/// The accessor.
/// </value>
[JsonProperty("accessor")]
public string Accessor { get; set; }

/// <summary>
/// Gets or sets the explicit maximum time to live.
/// </summary>
/// <value>
/// The explicit maximum time to live.
/// </value>
[JsonProperty("explicit_max_ttl")]
public int ExplicitMaximumTimeToLive { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this <see cref="CallingTokenInfo"/> is renewable.
/// </summary>
/// <value>
/// <c>true</c> if renewable; otherwise, <c>false</c>.
/// </value>
[JsonProperty("renewable")]
public bool Renewable { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public async Task<Secret<object>> CreateTokenAsync(CreateTokenRequest createToke
return await _polymath.MakeVaultApiRequest<Secret<object>>("v1/auth/token/" + suffix, HttpMethod.Post, request).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
}

public async Task<Secret<TokenInfo>> LookupAsync(string vaultToken)
public async Task<Secret<ClientTokenInfo>> LookupAsync(string clientToken)
{
Checker.NotNull(vaultToken, nameof(vaultToken));
Checker.NotNull(clientToken, nameof(clientToken));

var requestData = new { token = vaultToken };
return await _polymath.MakeVaultApiRequest<Secret<TokenInfo>>("v1/auth/token/lookup", HttpMethod.Post, requestData).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
var requestData = new { token = clientToken };
return await _polymath.MakeVaultApiRequest<Secret<ClientTokenInfo>>("v1/auth/token/lookup", HttpMethod.Post, requestData).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
}

public async Task<Secret<CallingTokenInfo>> LookupSelfAsync()
Expand Down
6 changes: 3 additions & 3 deletions src/VaultSharp/VaultSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>VaultSharp.snk</AssemblyOriginatorKeyFile>
<Title>VaultSharp</Title>
<Version>1.6.0.1</Version>
<Version>1.6.0.2</Version>
<Authors>Raja Nadar</Authors>
<Copyright>Copyright © 2020 Raja Nadar. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/rajanadar/VaultSharp</PackageProjectUrl>
Expand All @@ -22,8 +22,8 @@
This library is built with .NET Standard 1.3, .NET Standard 2.0, .NET Standard 2.1, .NET Framework 4.5 &amp; .NET 5 and hence is cross-platform across .NET Core 1.x, 2.x, 3.x, .NET Frameworks 4.x, Xamarin iOS, Android, Mac, UWP etc.</Description>
<RepositoryType>Github</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>1.6.0.1</AssemblyVersion>
<FileVersion>1.6.0.1</FileVersion>
<AssemblyVersion>1.6.0.2</AssemblyVersion>
<FileVersion>1.6.0.2</FileVersion>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageIcon>icon.png</PackageIcon>

Expand Down

0 comments on commit 29fff56

Please sign in to comment.