Skip to content
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

fix(ldap/auth): handle nil Auth struct when authentication fails #428

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Nov 7, 2023

// call to get a user token
user, err := vault.Logical().Write(path, options)
if err != nil {
	return nil, fmt.Errorf("unable to get user token: %w", err)
}

The above call does not return an error when the path exists but the password is wrong.

This results in a panic when trying to set the Vault token in the client.

panic: runtime error: invalid memory address or nil pointer dereference

A simple nil check on the Auth struct should suffice.

@ecrupper ecrupper requested a review from a team as a code owner November 7, 2023 16:53
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #428 (f4b9aad) into main (cc2ce1d) will decrease coverage by 0.42%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #428      +/-   ##
==========================================
- Coverage   42.10%   41.69%   -0.42%     
==========================================
  Files           7        7              
  Lines         304      307       +3     
==========================================
  Hits          128      128              
- Misses        158      161       +3     
  Partials       18       18              
Files Coverage Δ
vault/vault.go 55.71% <0.00%> (-2.50%) ⬇️

@ecrupper ecrupper merged commit 669ea15 into main Nov 7, 2023
8 of 12 checks passed
@ecrupper ecrupper deleted the fix/ldap-auth-panic branch November 7, 2023 20:38
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 this pull request may close these issues.

4 participants