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

Adding feature to include token generation for long process of spark. #618

Closed
wants to merge 23 commits into from

Conversation

rupesh3020
Copy link
Contributor

As we have feature to add HTTP headers in the header configuration but this token expires in one hour and spline does not have a mechanism to recreate token and make requests.

This feature adds the functionality by adding a new configuration authentication, where we can specify

  • clientid, clientsecret and other details to get tokens on the fly

rupesh agarwal added 2 commits February 24, 2023 15:21
+ If this contains client credential grant type variables then use auth
else normal request
+ Added authentication in config for http dispatcher types
@cerveada
Copy link
Contributor

Is this implementing Bearer authentification? (https://datatracker.ietf.org/doc/html/rfc6750)

I think it would make sense to have authentification.type property to allow other types in the future.

@cerveada
Copy link
Contributor

Currently, the build is failing because test do not compile. The tests must be modified to accommodate the changes in the dispatcher.

@rupesh3020
Copy link
Contributor Author

Currently, the build is failing because test do not compile. The tests must be modified to accommodate the changes in the dispatcher.

@cerveada Tests are fixed and i have tested the jar, it works fine. can you please check

@cerveada
Copy link
Contributor

@rupesh3020 thanks for fixing the tests and other issues, I will take a look.

@rupesh3020
Copy link
Contributor Author

@cerveada Issues fixed. Can you please check once. I have done functional testing

Comment on lines 60 to 67
case Some(map: scala.collection.immutable.Map[String, Any]) =>
val token = map.getOrElse("access_token", "").toString
if (token.nonEmpty) {
val expirationTime = Instant.now().plus(Duration.ofSeconds(map.getOrElse("expires_in", 0).toString.toLong))
val newToken = Token(token, expirationTime)
tokenCache = Some(newToken)
}
token
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case access_token is mandatory in the response(https://www.rfc-editor.org/rfc/rfc6749#section-5.1), so you may just assume it is there.

No need for map.getOrElse("access_token", "") or checking token.nonEmpty.

Just use map("access_token")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

throw new RuntimeException(failureMessage)
}
} else {
tokenCache.getOrElse(throw new RuntimeException(failureMessage)).tokenValue
Copy link
Contributor

Choose a reason for hiding this comment

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

in this place isTokenInvalid was already checked, so you can safely do tokenCache.get.tokenValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cerveada done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cerveada Can you please merge if everything looks good as we are waiting for this feature.

Copy link
Contributor

@cerveada cerveada left a comment

Choose a reason for hiding this comment

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

LGTM

@wajda
Copy link
Contributor

wajda commented Mar 24, 2023

Sorry guys, I was really buried with other stuff recently, but I really would like to have a quick look it it. Give me an hour or two, I'll check it out. In general, yes, that's awesome feature, I'm not going to delay merge.

@sonarcloud
Copy link

sonarcloud bot commented Mar 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@wajda wajda mentioned this pull request Mar 24, 2023
@wajda
Copy link
Contributor

wajda commented Mar 28, 2023

@rupesh3020 Thank you very much for your contribution!. We've made a few changes to your code and merged it as another pull request - #631. So I'm closing this one for that reason.

@wajda wajda closed this Mar 28, 2023
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.

None yet

3 participants