Skip to content

Commit

Permalink
Merge pull request #12 from mitodl/remove-try-catch-on-uri
Browse files Browse the repository at this point in the history
Remove try catch around URI
  • Loading branch information
collinpreston authored Nov 14, 2023
2 parents 436f1cb + 5c15a64 commit 25960cd
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import org.keycloak.models.*;
import org.keycloak.services.resources.LoginActionsService;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -27,11 +26,6 @@ public void authenticate(AuthenticationFlowContext context) {
LoginFormsProvider form = context.form();
realmIdentityProvidersList.removeAll(identityProvidersLinkedWithUser);
String requestURI = session.getContext().getUri().getBaseUri().getPath();
try {
new URL(requestURI);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
UriBuilder uriBuilder = UriBuilder.fromUri(requestURI);
ClientModel client = session.getContext().getClient();
if (client != null) {
Expand All @@ -43,6 +37,11 @@ public void authenticate(AuthenticationFlowContext context) {
uriBuilder.queryParam(LoginActionsService.SESSION_CODE, accessCode);
}
URI baseUriWithCodeAndClientId = uriBuilder.build();
try {
new URI(baseUriWithCodeAndClientId.getPath());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
form.setAttribute("unlinkedProviders", new IdentityProviderBean(realm, session, realmIdentityProvidersList, baseUriWithCodeAndClientId));
}
super.authenticate(context);
Expand Down

0 comments on commit 25960cd

Please sign in to comment.