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

Expose check_pass for the use of various auth plugins and support bcrypt #3

Merged
merged 3 commits into from Sep 29, 2018

Conversation

@ngjaying
Copy link
Contributor

ngjaying commented Sep 29, 2018

This is a clone pr from #2 to base on emqx30 branch.
There are mainly 2 changes for this commit:

Allow hash type to be bcrypt in addition to {salt, bcrypt}. If bcrypt is specified, salt will be extracted from the password hash.
Refactor check_pass. This function duplicates in many auth plugins such as emqx_auth_mysql, emqx_auth_redis etc. Move check_pass into emqx_passwd and let auth plugins invoke this common function(this change reside in the auth plugins' repository) to remove duplicates.

Makefile Outdated
@@ -5,7 +5,7 @@ PROJECT_VERSION = 0.1
DEPS = pbkdf2 bcrypt

dep_pbkdf2 = git https://github.com/emqx/erlang-pbkdf2 2.0.2
dep_bcrypt = git https://github.com/emqx/erlang-bcrypt 0.5.2
dep_bcrypt = git https://github.com/emqx/erlang-bcrypt

This comment has been minimized.

Copy link
@huangdan

huangdan Sep 29, 2018

Add a tag for erlang-bcrypt.

-spec(check_pass(binary() | tuple(), binary() | tuple()) -> binary()).
check_pass({PassHash, Password}, bcrypt) ->
try binary:part(PassHash, {0,29}) of
{error, Error}->

This comment has been minimized.

Copy link
@huangdan

huangdan Sep 29, 2018

modify to {error, Error} ->


-type(hash_type() :: plain | md5 | sha | sha256 | pbkdf2 | bcrypt).

-export_type([hash_type/0]).

-spec(check_pass(binary() | tuple(), binary() | tuple()) -> binary()).
check_pass({PassHash, Password}, bcrypt) ->
try binary:part(PassHash, {0,29}) of

This comment has been minimized.

Copy link
@huangdan

huangdan Sep 29, 2018

modify to {0, 29}

@huangdan huangdan added this to the 3.0-beta.4 milestone Sep 29, 2018
@huangdan huangdan merged commit 4a6788d into emqx:emqx30 Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.