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

Add form based authentication #4821

Merged
merged 4 commits into from
Oct 27, 2019

Conversation

stuartwdouglas
Copy link
Member

Fixes #4348

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I added one minor comment.

And CI failed with:

[ERROR]   NoConfiguredRealmsTestCase.testSecureAccessFailure:32 1 expectation failed.
Expected status code <403> but was <401>.

which looks related to your changes.

clustered HTTP session support. Instead the authentication information is stored in an encrypted cookie, which can
be read by all members of the cluster (provided they all share the same encryption key).

The encryption key can be set using the `auth.session.encryption-key` property, and it must be at least 16 characters
Copy link
Member

Choose a reason for hiding this comment

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

Very minor but should it be:

Suggested change
The encryption key can be set using the `auth.session.encryption-key` property, and it must be at least 16 characters
The encryption key can be set using the `quarkus.http.auth.session.encryption-key` property, and it must be at least 16 characters

?

if (System.currentTimeMillis() > expire) {
return null;
}
return new RestoreResult(result.substring(sep + 1), (System.currentTimeMillis() - expire) > 1000 * 60); //new cookie every minute
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the newCookieNeeded timeout be configurable with the default of 1 minute ?

Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

StringBuilder contents = new StringBuilder();
//TODO: do we need random padding?
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you take a look at this change set pedroigor@fb0b13d ?

It is about using AES GCM so that we have another random value to encrypt blocks. I have also changed to 128 which I think is a enough and help to balance with performance. We can make this configurable too.

I'm not using association data as that would require us to keep some state. But would be nice in order to make sure the user presenting the cookie is in fact the one to which the cookie was set. But it does not compromise the security.

@stuartwdouglas
Copy link
Member Author

I have addressed all the comments

* is not suitable for production environments. This must be more than 16 characters long for security reasons
*/
@ConfigItem(name = "auth.session.encryption-key")
public String encryptionKey;
Copy link
Member

@sberyozkin sberyozkin Oct 27, 2019

Choose a reason for hiding this comment

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

@stuartwdouglas should an auth.session.encryption-key-location be added and recommended by default ? encryptionKey is a good start but I'm not sure it is good for the production either, unless we have #3937, which would be good, as the users would just type

auth.session.encryption-key=${my.encryption.key.from.vault}

CC @vsevel @dmlloyd

Copy link
Member Author

Choose a reason for hiding this comment

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

You can just set the QUARKUS_HTTP_AUTH_SESSION_ENCRYPTION_KEY env var and it will override.

Copy link
Member Author

Choose a reason for hiding this comment

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

Either way this can be done as a future enhancement if there is demand for it. FORM is supposed to be mostly for learning/small apps, for big apps keycloak is our recommended solution.

Copy link
Member

Choose a reason for hiding this comment

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

@stuartwdouglas That is fine. I'll create an issue to follow up. Was not really my intention to slow down the PR - but if we let the users to for ex provide the user passwords with the elytron-security-jdbc then there should be a way for them not put the secret key for protecting the cookie data in the clear form. But as I said, with Vault and the config indirection it will already be possible; adding a simple check to load it from a (hopefully secure) file system will just complement it.

@stuartwdouglas stuartwdouglas merged commit 38fef63 into quarkusio:master Oct 27, 2019
@stuartwdouglas stuartwdouglas added this to the 0.27.0 milestone Oct 27, 2019
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.

Implement Vert.x based FORM auth in the new security layer
4 participants