Skip to content

DoOIDCCallbackAsync should be allowed for an unauthenticated client #378

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
ezhevita opened this issue Mar 3, 2025 · 0 comments · May be fixed by #379
Open

DoOIDCCallbackAsync should be allowed for an unauthenticated client #378

ezhevita opened this issue Mar 3, 2025 · 0 comments · May be fixed by #379

Comments

@ezhevita
Copy link

ezhevita commented Mar 3, 2025

Describe the bug
DoOIDCCallbackAsync can't be called with an unauthenticated client, similar to #348

VaultSharp Version
1.17.5.1

Vault Version
1.18.4

Does this work with Vault CLI?
Yes

Sample Code Snippet

        var tempAuthMethod = new NullAuthMethodInfo();
        var tempClient = new VaultClient(new VaultClientSettings(vaultUri.ToString(), tempAuthMethod));
        var callbackUrl = (await tempClient.V1.Auth.JWT.GetOIDCAuthURLAsync($"{CallbackHost}/oidc/callback", roleName: "oidc-role", mountPoint: "oidc").ConfigureAwait(false)).Data.AuthorizationURL;

        // Getting callback data is omitted for brevity
        string state = "";
        string code = "";

        // Exception!
        var token = (await tempClient.V1.Auth.JWT.DoOIDCCallbackAsync(state, HttpUtility.ParseQueryString(callbackUri.Query)["nonce"], code, mountPoint: "oidc").ConfigureAwait(false)).AuthInfo.ClientToken;
public class NullAuthMethodInfo : CustomAuthMethodInfo
{
    public NullAuthMethodInfo() : base("null", () => null)
    {
    }
}

Exception Details/Stack Trace/Error Message

System.NullReferenceException: Object reference not set to an instance of an object.
   at VaultSharp.V1.AuthMethods.Custom.CustomAuthMethodLoginProvider.<GetVaultTokenAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at VaultSharp.Core.Polymath.<MakeVaultApiRequest>d__21`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at VaultSharp.V1.AuthMethods.JWT.JWTAuthMethodProvider.<DoOIDCCallbackAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at <application code>

Any additional info
Adding unauthenticated: true should be enough to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant