-
Notifications
You must be signed in to change notification settings - Fork 3
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
14.09.2023 issue-52: insert chat id, token, token alias into database if token is valid #65
base: master
Are you sure you want to change the base?
Conversation
@iColdLight thank you for your Pull Request. I'll assign someone to review it soon. If this PR solves a |
@h1alexbel please review this Pull Request. Deadline (when it should be merged or closed) is You should check if the requirements have been implemented (partially or in full), if there are unit tests covering the changes and if the CI build passes. Feel free to reject the PR or ask for changes if it's too big or not clear enough. Estimation here is |
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.
@iColdLight the ticket was to insert chat id, token, token alias and other stuff (can be just a placeholder for now) if the provided token is valid.
And this token is not JWT, it's a just simple GitHub token, simple string
WDYT?
pom.xml
Outdated
@@ -159,6 +160,11 @@ SOFTWARE. | |||
<artifactId>reactor-test</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<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.
@iColdLight sort your dependencies, compile/provided scope first,
and only then test one
Mono<Void> registerToken(@RequestBody final RequestToken request) | ||
throws Exception { | ||
return this.tokens.add(new TokenToAdd(request).value()); | ||
Mono<Void> registerToken(@RequestBody final RequestToken request) throws Exception { |
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.
@iColdLight I think, method should be public
throws Exception { | ||
return this.tokens.add(new TokenToAdd(request).value()); | ||
Mono<Void> registerToken(@RequestBody final RequestToken request) throws Exception { | ||
String token = request.getValue(); |
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.
@iColdLight make all your variables final
Mono<Void> registerToken(@RequestBody final RequestToken request) throws Exception { | ||
String token = request.getValue(); | ||
String secretKey = "your-secret-key"; | ||
|
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.
@iColdLight empty lines mean code smell, read this
@h1alexbel Don't forget to close this ticket before the deadline (2023-09-17T19:18:59). You are past the first half of the allowed period. |
Does it mean that I need to work on creating JWT TokenProvider, JWT TokenFIlter, JWT User, etc.? |
@iColdLight we don't need JWTs. We are dealing with simple text token from GitHub
|
@h1alexbel Looks like you've missed the task deadline (2023-09-17T19:18:59). You are now resigned from this task. Please stop working on it, you will not be paid. I will assign it to someone else soon. |
@h1alexbel I couldn't find any assignee for this task. This is either because there are no contributors with role Please, make sure there is at least one available contributor with the required role and the project can afford to pay them. |
Hi! |
@iColdLight it's okay with commits, but you can read this |
@h1alexbel reminder |
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.
@iColdLight check my comments, please
* Tokens. | ||
*/ | ||
private final Tokens tokens; | ||
/** |
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.
@iColdLight don't change the layout, please
@@ -0,0 +1,7 @@ | |||
package io.blamer.hub.exceptions; | |||
|
|||
public class TokenAlreadyExists extends RuntimeException{ |
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.
@iColdLight class can be final
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
@Component | ||
public class TokenValidated implements Tokens { |
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.
@iColdLight It's better to name this class just like Validated
, since your interface already saying that this is Tokens
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 didn't name my class Validated because we already have a class with that name
|
||
@Override | ||
public Mono<Void> add(final Token token) { | ||
return validateToken(token) |
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.
@iColdLight
This logic can be decorated, presented as at least 2 classes: first where you just insert token, and the second one where you check token validity and integrity, and then insert into database (reuse first object)
What do you think?
Added TokenInsertion class Reworked TokenValidation class Made TokenAlreadyExists final
/codex Could there be a problem here in terms of non-blocking interaction? |
@l3r8yJ Yes, there could be a problem with non-blocking interaction in the code. The However, the code does not utilize reactive operators like To ensure non-blocking interaction, the code should use reactive operators to compose the asynchronous operations and handle the results asynchronously. |
@iColdLight take note of this comment
it's an AI response, could be wrong |
Reworked validateAndInsertToken method in TokenValidation class
I made a change to my TokenValidation class to ensure non-blocking interaction. May you take a look? |
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.
@iColdLight core logic is fine, now is needed to pass the merge pipeline
@l3r8yJ take a look, please |
Added dependency for json web token in the pom.xml file
Added validateToken method in the TokenController class
Modified registerToken method to include validation of token in the TokenController class
PR-Codex overview
Focus of the PR:
This PR focuses on adding token validation and insertion functionality to the codebase.
Detailed summary:
TokenValidation
class inio.blamer.hub.pg
package.TokenValidation
implements theTokens
interface.validateAndInsertToken
method inTokenValidation
to validate and insert tokens.validateToken
method inTokenValidation
to validate tokens.checkIfTokenExists
method inTokenValidation
to check if a token already exists in the database.checkIfTokenExists
method.TokenAlreadyExists
exception inio.blamer.hub.exceptions
package.TokenInsertion
class inio.blamer.hub.pg
package to handle token insertion.TokenInsertion
implements theTokens
interface.add
method inTokenInsertion
to add tokens.TokenController
class inio.blamer.hub.controller
package.TokenController
constructor to accept aTokens
object with@Qualifier("tokenValidation")
.registerToken
method inTokenController
to use thetokens
object to add tokens.