Search code examples
umbracoumbraco8

Umbraco 8.0 Login Issues


am getting junk characters in the PostLogin API Response for Umbraco login. which is causing all other api's to show a 401 unauthorized error.

Even the isAuthenticated API is returning as false.

Umbraco is hosted version and we are running 8.2.0.

It is a standard installation. the LegacyEncoding is set to true.

This is the response i am getting. The leading characters are the junk characters. Image here

)]}', ---Junk Values
{"email":"xxxxxxxxxxxxxxxxxx","locale":"en-US","emailHash":"ac88ae0de8ce43ba72dac1cd208d4e87","userGroups":[],"remainingAuthSeconds":1200.0,"startContentIds":[],"startMediaIds":[],"avatars":[],"allowedSections":[],"id":-1,"name":"xxxxxxxxxxxx"}

Solution

  • It's not junk, it's part of AngularJS JSON security:

    "Protection from JSON Hijacking is provided if the server prefixes all JSON requests with following string ")]}',\n". AngularJS will automatically strip the prefix before processing it as JSON. For more information please visit JSON Hijacking Protection."

    https://docs.angularjs.org/guide/security#json-hijacking-protection

    You can also see the implementation in Umbraco source code:

    enter image description here