Skip to content

Commit

Permalink
(4.2.3) added basic and post client authentication for stat
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Feb 4, 2021
1 parent e591d54 commit fd7c6cb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;

import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
Expand All @@ -15,4 +12,8 @@ public interface StatService {
@GET
@Produces({MediaType.APPLICATION_JSON})
JsonNode stat(@HeaderParam("Authorization") String authorization, @QueryParam("month") String month);

@POST
@Produces({MediaType.APPLICATION_JSON})
JsonNode stat(@HeaderParam("Authorization") String authorization, @FormParam("month") String month, @FormParam("client_id") String clientId, @FormParam("client_secret") String clientSecret);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import org.gluu.oxauth.BaseTest;
import org.gluu.oxauth.client.BaseRequest;
import org.gluu.oxauth.client.service.ClientFactory;
import org.gluu.oxauth.client.service.StatService;
import org.gluu.oxauth.client.uma.wrapper.UmaClient;
Expand All @@ -23,6 +24,22 @@ public void stat(final String umaPatClientId, final String umaPatClientSecret) t

final StatService service = ClientFactory.instance().createStatService(issuer + "/oxauth/restv1/internal/stat");
final JsonNode node = service.stat("Bearer " + authorization.getAccessToken(), "202101");
assertTrue(node != null && node.isArray());
assertTrue(node != null && node.hasNonNull("response"));
}

@Test
@Parameters({"umaPatClientId", "umaPatClientSecret"})
public void statBasic(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final StatService service = ClientFactory.instance().createStatService(issuer + "/oxauth/restv1/internal/stat");
final JsonNode node = service.stat("Basic " + BaseRequest.getEncodedCredentials(umaPatClientId, umaPatClientSecret), "202101");
assertTrue(node != null && node.hasNonNull("response"));
}

@Test
@Parameters({"umaPatClientId", "umaPatClientSecret"})
public void statPost(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final StatService service = ClientFactory.instance().createStatService(issuer + "/oxauth/restv1/internal/stat");
final JsonNode node = service.stat(null, "202101", umaPatClientId, umaPatClientSecret);
assertTrue(node != null && node.hasNonNull("response"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ private void processBasicAuth(HttpServletRequest servletRequest, HttpServletResp
|| servletRequest.getRequestURI().endsWith("/revoke_session")
|| servletRequest.getRequestURI().endsWith("/userinfo")
|| servletRequest.getRequestURI().endsWith("/bc-authorize")
|| servletRequest.getRequestURI().endsWith("/stat")
|| servletRequest.getRequestURI().endsWith("/device_authorization")) {
Client client = clientService.getClient(username);
if (client == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public String authenticateImpl(HttpServletRequest servletRequest, boolean intera
|| servletRequest.getRequestURI().endsWith("/revoke")
|| servletRequest.getRequestURI().endsWith("/revoke_session")
|| servletRequest.getRequestURI().endsWith("/userinfo")
|| servletRequest.getRequestURI().endsWith("/stat")
|| servletRequest.getRequestURI().endsWith("/bc-authorize")
|| servletRequest.getRequestURI().endsWith("/device_authorization")))) {
boolean authenticated = clientAuthentication(credentials, interactive, skipPassword);
Expand Down

0 comments on commit fd7c6cb

Please sign in to comment.