-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Security framework for the API #2461
Conversation
private Map<String, Long> tokens = new HashMap<>(); | ||
|
||
public TokenRegistry() { | ||
this(() -> UUID.randomUUID().toString(), System::currentTimeMillis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to use SecureRandom for cryptographically secure randomness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UUID.randomUUID
uses SecureRandom
by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok.
} | ||
|
||
public TokenRegistry(RandomStringGenerator randomStringGenerator, TimeProvider timeProvider) { | ||
this.timeProvider = timeProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to use SecureRandom for cryptographically secure randomness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time provider is meant to provide actual time. It is used as abstraction for unit tests.
|
||
|
||
|
||
import com.github.javafaker.Faker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont find that class in the source code at https://github.com/Javafaker.
Do we really need that? It is one of those examples where I don't want to get new dependencies (unknown developer, small functionality)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, just saw its a test class. So then I dont care so much about that dependency anymore, but still would like to know better what the class provides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faker is random data generator. On the top level it has methods with categories.
private static String getRandomPasswordDifferentThan(String otherPassword) { | ||
String newPassword; | ||
do { | ||
newPassword = Faker.instance().internet().password(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is that supposed to do? internet() is a weird method name...
As said above I prefer to not add that dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, just saw its a test class. So then I dont care so much about that dependency anymore, but still would like to know better what the class provides.
I've substituted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
I will merge master after the PR. Please update your branch afterwards to be in sync. |
No description provided.