Skip to content

Commit

Permalink
Prefix OIDC DevUI service path with forward slash
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Sep 29, 2022
1 parent 18aa6ab commit 06566c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private FileTime getRealmFileLastModifiedDate(Optional<String> realm) {

private void createDefaultRealm(String keycloakUrl, Map<String, String> users, String oidcClientId,
String oidcClientSecret) {
RealmRepresentation realm = createRealmRep();
RealmRepresentation realm = createDefaultRealmRep();

realm.getClients().add(createClient(oidcClientId, oidcClientSecret));
for (Map.Entry<String, String> entry : users.entrySet()) {
Expand Down Expand Up @@ -637,7 +637,7 @@ private List<String> getUserRoles(String user) {
: roles;
}

private RealmRepresentation createRealmRep() {
private RealmRepresentation createDefaultRealmRep() {
RealmRepresentation realm = new RealmRepresentation();

realm.setRealm(getDefaultRealmName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
}

function testServiceWithAccessToken(){
var servicePath = $('#servicePath').val();
var servicePath = getServicePath();
$.post("testServiceWithToken",
{
serviceUrl: "http://localhost:" + port + servicePath,
Expand All @@ -129,7 +129,7 @@
}

function testServiceWithIdToken(){
var servicePath = $('#servicePath').val();
var servicePath = getServicePath();
$.post("testServiceWithToken",
{
serviceUrl: "http://localhost:" + port + servicePath,
Expand Down Expand Up @@ -253,9 +253,23 @@
return token;
}
}

function printLoginError(){
var search = window.location.search;
var errorDescription = search.match(/error_description=([^&]+)/)[1];
$('#errorDescription').append("<i class='far fa-times-circle text-danger px-2'></i>");
$('#errorDescription').append("<span class='text-primary px-1'>" + "Login error: " + decodeURI(errorDescription).replaceAll("+", " ") + "</span>");
}

{/if}
{/if}

{#if info:oidcApplicationType is 'web-app'}
function signInToService(servicePath) {
window.open("http://localhost:" + port + servicePath);
}
{/if}

{#if info:oidcGrantType is 'password'}

function testServiceWithPassword(userName, password, servicePath){
Expand Down Expand Up @@ -394,15 +408,9 @@
$('#results').append("<br/>");
}

function printLoginError(){
var search = window.location.search;
var errorDescription = search.match(/error_description=([^&]+)/)[1];
$('#errorDescription').append("<i class='far fa-times-circle text-danger px-2'></i>");
$('#errorDescription').append("<span class='text-primary px-1'>" + "Login error: " + decodeURI(errorDescription).replaceAll("+", " ") + "</span>");
}

function signInToService(servicePath) {
window.open("http://localhost:" + port + servicePath);
function getServicePath() {
var servicePath = $('#servicePath').val();
return servicePath.startsWith("/") ? servicePath : ("/" + servicePath);
}

function clearResults() {
Expand Down Expand Up @@ -607,7 +615,7 @@ <h5 class="card-title text-light">Decoded</h5>
</div>
<div class="row my-2">
<div class="col offset-md-2">
<button onclick="testServiceWithPassword($('#userName').val(), $('#password').val(), $('#servicePath').val());" class="btn btn-primary btn-block" title="Test service">Test service</button>
<button onclick="testServiceWithPassword($('#userName').val(), $('#password').val(), getServicePath());" class="btn btn-primary btn-block" title="Test service">Test service</button>
</div>
<div class="float-right">
{#if info:swaggerIsAvailable??}
Expand Down Expand Up @@ -648,7 +656,7 @@ <h5 class="card-title text-light">Decoded</h5>
</div>
<div class="row my-2">
<div class="col offset-md-2">
<button onclick="testServiceWithClientCredentials($('#servicePath').val());" class="btn btn-primary btn-block" title="Test service">Test service</button>
<button onclick="testServiceWithClientCredentials(getServicePath());" class="btn btn-primary btn-block" title="Test service">Test service</button>
</div>
<div class="float-right">
{#if info:swaggerIsAvailable??}
Expand Down Expand Up @@ -687,7 +695,7 @@ <h5 class="card-title text-light">Decoded</h5>
</div>
<div class="row my-2">
<div class="col offset-md-2">
<button onclick="signInToService($('#servicePath').val());" class="btn btn-success btn-block" title="Log into your Web Application">Log into your Web Application</button>
<button onclick="signInToService(getServicePath());" class="btn btn-success btn-block" title="Log into your Web Application">Log into your Web Application</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 06566c0

Please sign in to comment.