default web origin is redirect uris

This commit is contained in:
Bill Burke 2014-05-20 17:40:45 -04:00
parent 8e79f550b0
commit ae3c4e8459
3 changed files with 23 additions and 3 deletions

View file

@ -268,11 +268,11 @@ module.controller('ApplicationDetailCtrl', function($scope, $document, realm, ap
Notifications.error("You must specify at least one redirect uri"); Notifications.error("You must specify at least one redirect uri");
} else { } else {
// automatically add redirects to web origins // automatically add redirects to web origins
var parser = $document.createElement('a'); var parser = document.createElement('a');
var originSet = {}; var originSet = {};
for (var i = 0; i < $scope.application.redirectUris.length; i++) { for (var i = 0; i < $scope.application.redirectUris.length; i++) {
parser.href = $scope.application.redirectUris[i]; parser.href = $scope.application.redirectUris[i];
var origin = href.protocol + "//" + href.host; var origin = parser.protocol + "//" + parser.host;
originSet[origin] = true; originSet[origin] = true;
} }
for (var key in originSet) { for (var key in originSet) {

View file

@ -90,7 +90,7 @@
data-ng-model="application.adminUrl"> data-ng-model="application.adminUrl">
</div> </div>
</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> <label class="col-sm-2 control-label" for="newWebOrigin">Web Origin</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div ng-repeat="webOrigin in application.webOrigins" class="row kc-item-deletable"> <div ng-repeat="webOrigin in application.webOrigins" class="row kc-item-deletable">

View file

@ -80,6 +80,26 @@ public class ApplicationManager {
logger.debugv("Application: {0} webOrigin: {1}", resourceRep.getName(), webOrigin); logger.debugv("Application: {0} webOrigin: {1}", resourceRep.getName(), webOrigin);
applicationModel.addWebOrigin(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) { if (resourceRep.getDefaultRoles() != null) {