Commit fe53e273 authored by michael.simon's avatar michael.simon
Browse files

Add oidc rest endpoint for metadata

parent 84d020d6
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.oauth;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/oidc")
public class JaxRsOidcApplicationActivator extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
resources.add(OidcWellknownController.class);
return resources;
}
}
package edu.kit.scc.webreg.oauth;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.slf4j.Logger;
import com.nimbusds.oauth2.sdk.id.Issuer;
import com.nimbusds.openid.connect.sdk.SubjectType;
import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
import net.minidev.json.JSONObject;
@Path("/realms")
public class OidcWellknownController {
@Inject
private Logger logger;
@GET
@Path("/{realm}/.well-known/openid-configuration")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject wellknown(@PathParam("realm") String serviceShortName)
throws ServletException {
try {
List<SubjectType> subjectTypeList = new ArrayList<SubjectType>();
subjectTypeList.add(SubjectType.PAIRWISE);
subjectTypeList.add(SubjectType.PUBLIC);
OIDCProviderMetadata metadata = new OIDCProviderMetadata(new Issuer("https://bwidm.scc.kit.edu/oidc/auth/realms/bwidm"),
subjectTypeList, new URI("https://bwidm.scc.kit.edu/oidc/jwk"));
logger.debug(metadata.toJSONObject().toString());
return metadata.toJSONObject();
} catch (URISyntaxException e) {
throw new ServletException(e);
}
}
}
...@@ -10,10 +10,27 @@ ...@@ -10,10 +10,27 @@
******************************************************************************/ ******************************************************************************/
package edu.kit.scc.webreg.rest; package edu.kit.scc.webreg.rest;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath; import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; import javax.ws.rs.core.Application;
@ApplicationPath("/rest") @ApplicationPath("/rest")
public class JaxRsApplicationActivator extends Application { public class JaxRsApplicationActivator extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
resources.add(AttributeQueryController.class);
resources.add(DirectAuthController.class);
resources.add(EcpController.class);
resources.add(ExternalRegistryController.class);
resources.add(ExternalUserController.class);
resources.add(GroupController.class);
resources.add(ImageController.class);
resources.add(ServiceAdminController.class);
resources.add(UserController.class);
return resources;
}
} }
...@@ -105,6 +105,7 @@ public class SecurityFilter implements Filter { ...@@ -105,6 +105,7 @@ public class SecurityFilter implements Filter {
path.startsWith("/saml/") || path.startsWith("/saml/") ||
path.startsWith("/logout/") || path.startsWith("/logout/") ||
path.startsWith("/error/") || path.startsWith("/error/") ||
path.startsWith("/oidc/") ||
path.equals("/favicon.ico") path.equals("/favicon.ico")
) { ) {
chain.doFilter(servletRequest, servletResponse); chain.doFilter(servletRequest, servletResponse);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment