default web origin is redirect uris
This commit is contained in:
parent
8e79f550b0
commit
ae3c4e8459
3 changed files with 23 additions and 3 deletions
|
@ -268,11 +268,11 @@ module.controller('ApplicationDetailCtrl', function($scope, $document, realm, ap
|
|||
Notifications.error("You must specify at least one redirect uri");
|
||||
} else {
|
||||
// automatically add redirects to web origins
|
||||
var parser = $document.createElement('a');
|
||||
var parser = document.createElement('a');
|
||||
var originSet = {};
|
||||
for (var i = 0; i < $scope.application.redirectUris.length; i++) {
|
||||
parser.href = $scope.application.redirectUris[i];
|
||||
var origin = href.protocol + "//" + href.host;
|
||||
var origin = parser.protocol + "//" + parser.host;
|
||||
originSet[origin] = true;
|
||||
}
|
||||
for (var key in originSet) {
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
data-ng-model="application.adminUrl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" data-ng-show="!application.bearerOnly">
|
||||
<div class="form-group" data-ng-show="!application.bearerOnly && !create">
|
||||
<label class="col-sm-2 control-label" for="newWebOrigin">Web Origin</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-repeat="webOrigin in application.webOrigins" class="row kc-item-deletable">
|
||||
|
|
|
@ -80,6 +80,26 @@ public class ApplicationManager {
|
|||
logger.debugv("Application: {0} webOrigin: {1}", resourceRep.getName(), webOrigin);
|
||||
applicationModel.addWebOrigin(webOrigin);
|
||||
}
|
||||
} else {
|
||||
// add origins from redirect uris
|
||||
if (resourceRep.getRedirectUris() != null) {
|
||||
Set<String> origins = new HashSet<String>();
|
||||
for (String redirectUri : resourceRep.getRedirectUris()) {
|
||||
logger.info("add redirectUri to origin: " + redirectUri);
|
||||
if (redirectUri.startsWith("http:")) {
|
||||
URI uri = URI.create(redirectUri);
|
||||
String origin = uri.getScheme() + "://" + uri.getHost();
|
||||
if (uri.getPort() != -1) {
|
||||
origin += ":" + uri.getPort();
|
||||
}
|
||||
logger.debugv("adding default application origin: {0}" , origin);
|
||||
origins.add(origin);
|
||||
}
|
||||
}
|
||||
if (origins.size() > 0) {
|
||||
applicationModel.setWebOrigins(origins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resourceRep.getDefaultRoles() != null) {
|
||||
|
|
Loading…
Reference in a new issue