Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import com.networknt.handler.LightHttpHandler;
import com.networknt.oauth.cache.CacheStartupHookProvider;
import com.networknt.oauth.cache.model.Client;
import com.networknt.status.Status;
import com.networknt.utility.Util;
import io.undertow.UndertowLogger;
import io.undertow.security.api.AuthenticationMechanism;
import io.undertow.security.api.SecurityContext;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.form.FormData;
import io.undertow.server.handlers.form.FormDataParser;
Expand All @@ -18,7 +14,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Oauth2CodePostHandler extends CodeAuditHandler implements LightHttpHandler {
static final Logger logger = LoggerFactory.getLogger(Oauth2CodeGetHandler.class);
Expand All @@ -39,16 +37,20 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
final String clientId = jClientId.getValue();
String redirectUri = jRedirectUri == null ? null : jRedirectUri.getValue();
final String state = jState == null ? null : jState.getValue();

if(logger.isDebugEnabled()) {
logger.debug("client_id = " + clientId + " state = " + state + " redirectUri = " + redirectUri);
}
// check if the client_id is valid
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
Client client = clients.get(clientId);
if(client == null) {
if(logger.isDebugEnabled()) logger.debug("client is not found for clientId = " + clientId);
setExchangeStatus(exchange, CLIENT_NOT_FOUND, clientId);
processAudit(exchange);
} else {
final SecurityContext context = exchange.getSecurityContext();
String userId = context.getAuthenticatedAccount().getPrincipal().getName();
if(logger.isDebugEnabled()) logger.debug("userId = " + userId);
Set<String> roles = context.getAuthenticatedAccount().getRoles();
Map<String, String> codeMap = new HashMap<>();
codeMap.put("userId", userId);
Expand Down
2 changes: 1 addition & 1 deletion provider/docker/Dockerfile-Slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM openjdk:11.0.3-slim
ADD target/oauth2-provider server.jar
ADD target/oauth2-provider.jar server.jar
CMD ["/bin/sh","-c","java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"]