Neilk1021 commented on code in PR #7055:
URL: https://github.com/apache/texera/pull/7055#discussion_r3715319632
##########
amber/src/main/scala/org/apache/texera/web/resource/auth/GoogleAuthResource.scala:
##########
@@ -53,64 +63,36 @@ class GoogleAuthResource {
@Path("/clientid")
def getClientId: String = clientId
- @POST
- @Consumes(Array(MediaType.TEXT_PLAIN))
- @Produces(Array(MediaType.APPLICATION_JSON))
- @Path("/login")
- def login(credential: String): TokenIssueResponse = {
- val idToken =
+ /**
+ * Verify `credential` against Google, yielding its payload, or None if it
is not a valid
+ * token for this client. The only seam that reaches the network, so tests
override it
+ * instead of signing a token; kept a method rather than a constructor
parameter because
+ * Jersey instantiates this resource from `classOf[GoogleAuthResource]`.
+ */
+ protected def verifiedPayload(credential: String):
Option[GoogleIdToken.Payload] =
+ Option(
new GoogleIdTokenVerifier.Builder(new NetHttpTransport,
GsonFactory.getDefaultInstance)
.setAudience(
Collections.singletonList(clientId)
Review Comment:
Added refactor to handle 401 / 500 split by wrapping the statement in a try
catch and then verifying after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]