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

support getting caller and group information from multiple tokens #26719

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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2022 IBM Corporation and others.
* Copyright (c) 2013, 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -31,5 +31,10 @@ public class PayloadConstants {
public static final String CLASS_REFERENCE = "acr";
public static final String METHODS_REFERENCE = "amr";
public static final String SESSION_ID = "sid";

public static final String USER_PRINCIPAL_NAME = "upn";

public static final String GROUP = "groupIds";
Copy link
Member

Choose a reason for hiding this comment

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

Would it make more sense to call this GROUP_IDS instead of GROUP?

public static final String GROUPS = "groups";

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public class MessageConstants extends com.ibm.ws.security.fat.common.MessageCons
public static final String CWWKS1741W_OIDC_CLIENT_NONE_ALG = "CWWKS1741W";
public static final String CWWKS1743E_REUSED_JTI = "CWWKS1743E";
public static final String CWWKS1747E_JWK_RETRIEVE_FAILED = "CWWKS1747E";
public static final String CWWKS1748E_USERINFO_REQUEST_NOT_AUTHORIZED = "CWWKS1748E";
public static final String CWWKS1749E_SUB_DID_NOT_MATCH_ID_TOKEN = "CWWKS1749E";
public static final String CWWKS1756E_OIDC_IDTOKEN_SIGNATURE_VERIFY_ERR = "CWWKS1756E";
public static final String CWWKS1761E_SIG_ALG_MISMATCH = "CWWKS1761E";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class TokenEndpointServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final String servletName = "TokenEndpointServlet";
private String token = null;
private String idt = null;
Copy link
Member

Choose a reason for hiding this comment

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

Would really prefer this to be called something like overrideIdToken or idTokenOverride or idTokenRequestParameter so it's more descriptive than the cryptic idt.


public TokenEndpointServlet() {
}
Expand Down Expand Up @@ -83,6 +84,7 @@ protected void handleSaveTokenRequest(HttpServletRequest req, HttpServletRespons
String builderId = null;
try {
token = req.getParameter("overrideToken");
idt = req.getParameter("overrideIDToken");
if (token == null) { // if the calling test hacked up a token that we want to use, skip creating a new token
builderId = req.getParameter("builderId");
System.out.println("Using builderId: " + builderId);
Expand All @@ -104,6 +106,11 @@ protected void handleSaveTokenRequest(HttpServletRequest req, HttpServletRespons
builtToken = builder.buildJwt();
token = builtToken.compact();
}
if (idt == null) {
idt = token;
} else {
System.out.println("Saving id token: " + idt);
}
} catch (Exception e) {
writer.println(e);
throw new ServletException(e.toString());
Expand Down Expand Up @@ -139,7 +146,7 @@ protected void handleReturnTokenRequest(HttpServletRequest req, HttpServletRespo
theResponse.put("expires_in", 7199);
theResponse.put("scope", "openid profile");
theResponse.put("refresh_token", "21MhoIC95diaQo9tb5UpFBDFlHh45NixhcKkCwRipszH6WIzKz");
theResponse.put("id_token", token);
theResponse.put("id_token", idt);

PrintWriter writer = resp.getWriter();
// writer.println("ServletName: " + servletName);
Expand Down
7 changes: 7 additions & 0 deletions dev/com.ibm.ws.security.oidc.client_fat.4/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="fat/src"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
23 changes: 23 additions & 0 deletions dev/com.ibm.ws.security.oidc.client_fat.4/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.ws.security.oidc.client_fat.4</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
compileErrorAction=build
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Ant properties
#Automatically generated by the ant prepare.settings.files task
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=java;javax;org;com;
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/** */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=false
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
55 changes: 55 additions & 0 deletions dev/com.ibm.ws.security.oidc.client_fat.4/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#*******************************************************************************
# Copyright (c) 2023 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# IBM Corporation - initial API and implementation
#*******************************************************************************
-include= ~../cnf/resources/bnd/bundle.props
bVersion=1.0

src: \
fat/src

fat.project: true
publish.wlp.jar.disabled: true

tested.features: jsp-2.3, el-3.0, restfulwsclient-3.0, restfulws-3.0,\
appsecurity-4.0, expressionlanguage-4.0, pages-3.0,\
restfulws-3.1, appsecurity-5.0, pages-3.1

Import-Package: \
!*.internal.*, \
!com.ibm.ws.kernel.boot.cmdline, \
org.apache.commons.codec.binary,\
org.jose4j.*, \
*

-buildpath: \
com.ibm.websphere.javaee.jsonp.1.0;version=latest,\
com.ibm.websphere.javaee.servlet.3.0;version=latest,\
io.openliberty.com.google.gson;version=latest,\
com.ibm.ws.com.google.guice.2.0;version=latest,\
com.ibm.ws.com.meterware.httpunit.1.7;version=latest,\
httpunit:httpunit;version='1.7',\
com.ibm.ws.kernel.service;version=latest,\
com.ibm.ws.net.oauth.jsontoken.1.1-r42;version=latest,\
com.ibm.ws.org.openid4java.0.9.7;version=latest,\
com.ibm.ws.security.fat.common;version=latest,\
com.ibm.ws.security.fat.common.jwt;version=latest,\
com.ibm.ws.security.fat.common.social;version=latest,\
com.ibm.ws.security.oauth.oidc_fat.common;version=latest,\
com.ibm.ws.security.openidconnect.clients.common;version=latest,\
io.openliberty.org.apache.commons.codec;version=latest,\
io.openliberty.org.apache.commons.logging;version=latest,\
net.sourceforge.htmlunit:htmlunit;version='2.44.0',\
com.ibm.ws.org.apache.directory.server;version=latest,\
com.ibm.ws.org.apache.commons.lang3;version=latest,\
com.ibm.ws.org.jose4j;version=latest,\
com.ibm.json4j;version=latest

Loading