fix cors example
This commit is contained in:
parent
19e1ddff1d
commit
790fd1d94d
9 changed files with 20 additions and 14 deletions
|
@ -59,7 +59,7 @@ Step 5: Login and Observe Apps
|
|||
---------------------------------------
|
||||
Try going to the customer app and view customer data:
|
||||
|
||||
[http://localhost:8080/angular-product/index.html](http://localhost:8080/angular-product/index.html)
|
||||
[http://localhost:8080/angular-cors-product/index.html](http://localhost:8080/angular-cors-product/index.html)
|
||||
|
||||
This should take you to the auth-server login screen. Enter username: bburke@redhat.com and password: password. You
|
||||
should be brought back to a simple and boring HTML page. Click the Reload button to show the product listing. Reload
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<description/>
|
||||
|
||||
<build>
|
||||
<finalName>angular-product</finalName>
|
||||
<finalName>angular-cors-product</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jboss.as.plugins</groupId>
|
||||
|
|
|
@ -18,7 +18,7 @@ angular.element(document).ready(function ($http) {
|
|||
console.log('here login');
|
||||
auth.loggedIn = true;
|
||||
auth.authz = keycloakAuth;
|
||||
auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/" + keycloakAuth.realm + "/tokens/logout?redirect_uri=/angular-product/index.html";
|
||||
auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/" + keycloakAuth.realm + "/tokens/logout?redirect_uri=http://localhost:8080/angular-cors-product/index.html";
|
||||
module.factory('Auth', function() {
|
||||
return auth;
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ module.controller('GlobalCtrl', function($scope, $http) {
|
|||
$scope.products = [];
|
||||
$scope.roles = [];
|
||||
$scope.reloadData = function() {
|
||||
$http.get("http://localhost-db:8080/database/products").success(function(data) {
|
||||
$http.get("http://localhost-db:8080/cors-database/products").success(function(data) {
|
||||
$scope.products = angular.fromJson(data);
|
||||
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"realm" : "cors",
|
||||
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
|
||||
"auth-server-url" : "/auth",
|
||||
"auth-server-url" : "http://localhost-auth:8080/auth",
|
||||
"ssl-required" : "external",
|
||||
"resource" : "angular-product",
|
||||
"resource" : "angular-cors-product",
|
||||
"public-client" : true
|
||||
}
|
|
@ -38,18 +38,18 @@
|
|||
},
|
||||
"scopeMappings": [
|
||||
{
|
||||
"client": "angular-product",
|
||||
"client": "angular-cors-product",
|
||||
"roles": ["user"]
|
||||
}
|
||||
],
|
||||
"applications": [
|
||||
{
|
||||
"name": "angular-product",
|
||||
"name": "angular-cors-product",
|
||||
"enabled": true,
|
||||
"publicClient": true,
|
||||
"baseUrl": "/angular-product/index.html",
|
||||
"baseUrl": "http://localhost:8080/angular-cors-product/index.html",
|
||||
"redirectUris": [
|
||||
"/angular-product/*"
|
||||
"http://localhost:8080/angular-cors-product/*"
|
||||
],
|
||||
"webOrigins": [
|
||||
"http://localhost:8080"
|
||||
|
@ -59,7 +59,7 @@
|
|||
"applicationScopeMappings": {
|
||||
"realm-management": [
|
||||
{
|
||||
"client": "angular-product",
|
||||
"client": "angular-cors-product",
|
||||
"roles": ["realm-admin"]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>database</finalName>
|
||||
<finalName>cors-database</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jboss.as.plugins</groupId>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"realm" : "cors-realm",
|
||||
"resource" : "database-service",
|
||||
"resource" : "cors-database-service",
|
||||
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
|
||||
"bearer-only" : true,
|
||||
"ssl-required": "external",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
|
||||
<module-name>database</module-name>
|
||||
<module-name>cors-database</module-name>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
|
|
|
@ -181,6 +181,9 @@ public class RepresentationToModel {
|
|||
if (rep.getScopeMappings() != null) {
|
||||
for (ScopeMappingRepresentation scope : rep.getScopeMappings()) {
|
||||
ClientModel client = newRealm.findClient(scope.getClient());
|
||||
if (client == null) {
|
||||
throw new RuntimeException("Unknown client specification in realm scope mappings");
|
||||
}
|
||||
for (String roleString : scope.getRoles()) {
|
||||
RoleModel role = newRealm.getRole(roleString.trim());
|
||||
if (role == null) {
|
||||
|
@ -558,6 +561,9 @@ public class RepresentationToModel {
|
|||
public static void createApplicationScopeMappings(RealmModel realm, ApplicationModel applicationModel, List<ScopeMappingRepresentation> mappings) {
|
||||
for (ScopeMappingRepresentation mapping : mappings) {
|
||||
ClientModel client = realm.findClient(mapping.getClient());
|
||||
if (client == null) {
|
||||
throw new RuntimeException("Unknown client specified in application scope mappings");
|
||||
}
|
||||
for (String roleString : mapping.getRoles()) {
|
||||
RoleModel role = applicationModel.getRole(roleString.trim());
|
||||
if (role == null) {
|
||||
|
|
Loading…
Reference in a new issue