8000 JDBC QueryAndEncodeDatabaseAuthenticationHandler by mmoayyed · Pull Request #665 · apereo/cas · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JDBC QueryAndEncodeDatabaseAuthenticationHandler #665

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

Merged
merged 11 commits into from
Sep 19, 2014
Merged

JDBC QueryAndEncodeDatabaseAuthenticationHandler #665

merged 11 commits into from
Sep 19, 2014

Conversation

mmoayyed
Copy link
Member

This is a JDBC authn handler that has support for dynamic salts, put together by @chasegawa ; I mostly just added support for field names and made it more generic.

This is what it can do:

  1. Can be configured with a message digest algorithm SHA-512
  2. Can be configured with a sql statement
  3. Can be configured with a static salt
  4. ... and can retrieve dynamic salts from the database table
  5. ... and can retrieve number of iterations from the database table
  6. Compliant with principal transformers and password encoders

The handler will:

  1. Construct the message digestion algorithm prep
  2. Execute the sql query to find the user
  3. Add the encoded password to digest
  4. Add static salt to digest
  5. Locate the dynamic salt from tuple, if available, add to digest
  6. Iterate over the result per configuration
  7. Compare the result against password db value

Unit tests accompany the PR.

@mmoayyed mmoayyed added this to the 4.1 milestone Aug 18, 2014
@coveralls
Copy link

Coverage Status

Coverage increased (+0.26%) when pulling 7163040 on Unicon:jdbc-handler-dynasalt into 4420059 on Jasig:master.

/**
* Instantiates a new Prefix suffix principal name transformer.
*/
public PrefixSuffixPrincipalNameTransformer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure to see the benefit of having this constructor. Isn't it already the default behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you overload the constructor, the default "goes away". So we are just keeping this to make sure existing default behavior stays where it was.

Copy link
Contributor

Choose a reason for hiding this comment

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

Although it's good to keep backward compatibility, we have huge breaking changes in 4.1 (I'm thinking about the services definition).

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is tha 8000 t both prefix and suffix are optional. It doesn't make sense to create a class with both value as null, but it isn't possible to provide options through ctors to just set one and not the other. This is how we can keep both optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure of my understanding: you mean using the default constructor and then only one of the setters, don't you?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly.

I can do:

var trans = new PrefixSuffixPrincipalNameTransformer()
trans.setPrefix(...)

Or:

var trans = new PrefixSuffixPrincipalNameTransformer()
trans.setSuffix(...)

Or:

var trans = new PrefixSuffixPrincipalNameTransformer("prefix", "suffix")

But this would be ugly, if I didnt have the default ctor:

var trans = new PrefixSuffixPrincipalNameTransformer(null, "suffix")

@mmoayyed
Copy link
Member Author

Moved the digest object down to be local. This should be ready so far as it goes.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.27%) when pulling b3a9f2c on Unicon:jdbc-handler-dynasalt into 4420059 on Jasig:master.

* @return the digested password
*/
private byte[] digestEncodedPassword(final String encodedPassword, final Map<String, Object> values) {
final MessageDigest messageDigest = DigestUtils.getDigest(this.algorithmName);
Copy link
Contributor

Choose a reason for hiding this comment

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

MessageDigest seems to be a low-level class: wasn't there some more elaborated solution (based on Shiro for example)?

Copy link
< 8000 span aria-label="This user is a member of the apereo organization." data-view-component="true" class="tooltipped tooltipped-n"> Member Author

Choose a reason for hiding this comment

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

Shiro provides default impls of MessageDigest. At the end, you'd still be working with a message digest, but the impl is provided by shiro based on the algorithm provided. We do have commons codec that does this well, and I am not sure pulling another library in just to do the hashing bit for something we already have a component for is all too helpful....unless shiro does something monumentally better than codec to justify the leap.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah excellent. That's what I was looking for. Thanks. I'll see if I can tweak the PR. (Pulling in Shiro just for hashing seems a bit overkill, but I think it will be useful down the road).

@mmoayyed
Copy link
Member Author

This PR is now based on shiro.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.25%) when pulling 180afcc on Unicon:jdbc-handler-dynasalt into da2904b on Jasig:master.

@leleuj
Copy link
Contributor
leleuj commented Sep 5, 2014

+1

@mmoayyed
Copy link
Member Author
mmoayyed commented Sep 9, 2014

bump.

@mmoayyed
Copy link
Member Author

Bump. Proceeding to merge, if there are no other comments.

@mmoayyed
Copy link
Member Author

Assuming things are ok with this PR, I'll get this merged by tomorrow.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.23%) when pulling 146be36 on Unicon:jdbc-handler-dynasalt into a8539cf on Jasig:master.

mmoayyed pushed a commit that referenced this pull request Sep 19, 2014
JDBC QueryAndEncodeDatabaseAuthenticationHandler
@mmoayyed mmoayyed merged commit bd2e73d into apereo:master Sep 19, 2014
@mmoayyed mmoayyed deleted the jdbc-handler-dynasalt branch September 19, 2014 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0