Sure...
HttpService.insertNewUser = function(user) {
var deferred = $q.defer();
//user object brings from the interface, firstName, lastName, userName and
email
//here, it receives some other properties
user.attributes = {};
user.emailVerified = false;
user.enabled = true;
user.requiredActions = ["VERIFY_EMAIL", "UPDATE_PASSWORD"];
var url = service.getUrlBase() + "/users";
//var url =
https://sso-server/auth/admin/realms/realmname/users
$http.post(url, user).then(
function(response) {
deferred.resolve(
"User " + user.firstName + " " + user.lastName + " (" +
user.email + ")
successfully added"
);
},
function(retorno) {
deferred.reject(
retorno.status + ": " + retorno.statusText + " [" + retorno.data +
"]"
);
}
);
return deferred.promise;
}
that response in the first callback from the $http.post should be able to
access the headers array, inlcuding location, but it can't.
response.headers() returns [].
Cordialmente.
Alex Gouvêa Vasconcelos
mailto:alexgv99@gmail.com
MSN: alexgv99(a)hotmail.com
http://about.me/alexgv99
2016-05-18 9:08 GMT-03:00 Thomas Darimont <thomas.darimont(a)googlemail.com>:
Okay,
Alex could you provide us with a small example (js) that reproduces this?
Cheers,
Thomas
Stian Thorgersen <sthorger(a)redhat.com> schrieb am Mi., 18. Mai 2016,
14:06:
> Maybe, not 100% sure though
>
> On 18 May 2016 at 11:21, Thomas Darimont <thomas.darimont(a)googlemail.com>
> wrote:
>
>> Hello,
>>
>> Would it be enough to add .exposedHeaders("Location") where the CORS
>> headers are configured like:
>> org.keycloak.services.resources.admin.AdminRoot#getRealmsAdmin?
>>
>>
https://github.com/keycloak/keycloak/blob/92db7b3618852d953e5b53482668c3f...
>>
>> Cheers,
>> Thomas
>>
>> 2016-05-18 8:45 GMT+02:00 Stian Thorgersen <sthorger(a)redhat.com>:
>>
>>> Permitting the Location header has to be changed in the admin endpoints
>>> on the Keycloak server side. Adding those properties to keycloak.json only
>>> control CORS headers for services in your own application.
>>>
>>> Please create a JIRA issue for this, you can mark it as a bug as the
>>> admin endpoints should support CORS.
>>>
>>> On 16 May 2016 at 23:58, Alex Gouvêa Vasconcelos <alexgv99(a)gmail.com>
>>> wrote:
>>>
>>>> I'm trying to follow the link obtained in a 201 (user created) in
the
>>>> Keycloak API but I can't access the "location" header which
should be
>>>> returned in the response...
>>>>
>>>> $http.post(url, user)
>>>> .then(
>>>> function(response) { console.log(response.headers()); },
>>>> function(error) {}
>>>> )
>>>>
>>>> The whole response.header() collection is empty... yet, the chrome
>>>> developer console shows the url to the new resource...
>>>>
>>>> I think, maybe this is related to the problem described here (
>>>>
http://www.aaron-powell.com/posts/2013-11-28-accessing-location-header-in...),
>>>> but I have tryed to add the following lines to my keycloak.json and yet
no
>>>> success:
>>>> "enable-cors": true,
>>>> "cors-allowed-headers": "Location"
>>>>
>>>> Could anyone help me with that issue?
>>>>
>>>> Regards.
>>>> Alex Gouvêa Vasconcelos
>>>>
>>>>
>>>> _______________________________________________
>>>> keycloak-dev mailing list
>>>> keycloak-dev(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>>>
>>>
>>>
>>> _______________________________________________
>>> keycloak-dev mailing list
>>> keycloak-dev(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>>
>>
>>
>