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

feat($rootScope): verifier for MD5 salted passwords #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtrisc
Copy link

@mtrisc mtrisc commented Mar 17, 2025

Allow salted passwords hashed with MD5 to be verified. Accept salt as prefix or as suffix of the password. Don't allow to use as hasher.

new feature

Allow salted passwords hashed with MD5 to be verified. Accept salt as prefix or as suffix of the password. Don't allow to use as hasher.

new feature
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.

Project coverage is 98.45%. Comparing base (ae26eb6) to head (4f4a28a).
Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
md5salted/md5salted.go 93.02% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #58      +/-   ##
===========================================
- Coverage   100.00%   98.45%   -1.55%     
===========================================
  Files           10       15       +5     
  Lines          512      583      +71     
===========================================
+ Hits           512      574      +62     
- Misses           0        5       +5     
- Partials         0        4       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@muhlemmer muhlemmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the complete PR. Some suggestions on typos and gofmt.

Also added an extra testcase to keep 100% coverage.

), nil
}

// Verify parses encoded and verfies password against the checksum.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Verify parses encoded and verfies password against the checksum.
// Verify parses encoded and verifies password against the checksum.

}
c.setSaltPasswFunc(id)
if c.saltpasswfunc == nil {
return nil, fmt.Errorf("md5salted unknow identifier: %s", id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("md5salted unknow identifier: %s", id)
return nil, fmt.Errorf("md5salted unknown identifier: %s", id)

@muhlemmer
Copy link
Collaborator

Github is being weird now and not attaching pending comments to my review. Give me a minute

},
{
name: "wrong identifier",
args: args{"$md5salted-unknow$foo$foo"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args: args{"$md5salted-unknow$foo$foo"},
args: args{"$md5salted-unknown$foo$foo"},

Copy link
Collaborator

@muhlemmer muhlemmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that should be all :)

args: args{Password},
want: verifier.OK,
encoded: MD5SaltedEncodedP,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
},
},
{
name: "hash decode error",
args: args{Password},
want: verifier.Skip,
encoded: "$md5salted-prefix$c2FsdA==$~~~~~~~",
},

Comment on lines +4 to +8
"github.com/zitadel/passwap/internal/testvalues"
"reflect"
"testing"

"github.com/zitadel/passwap/verifier"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/zitadel/passwap/internal/testvalues"
"reflect"
"testing"
"github.com/zitadel/passwap/verifier"
"reflect"
"testing"
"github.com/zitadel/passwap/internal/testvalues"
"github.com/zitadel/passwap/verifier"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

3 participants