I recently started learning AngularJS, and I have the following sample code that does a REST callout from a Visualforce page - the code does a successful callout. My question: In the 'app.config' where we provide the Authorization header as a string value ('BASIC base64Hash'), base64Hash being the username:password hash, how is this secure? If I open up the page and hit inspect, I can grab the hash and decrypt the base64 to get the username:password.
P.S: Keep in mind that I recently got into AngularJS, and I know that the following procedure for a REST callout from AngularJS may not be the best practice. Which is why the question. :)
<apex:page standardStylesheets="false" showHeader="false">
<html ng-app="hello" lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script>
<script>
// define the app
var demoApp = angular.module('hello', []);
demoApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.common['Authorization'] = 'BASIC base64Hash';
}]);
demoApp.controller('helloController', function($scope, $http){
$http({
method: "GET",
url: "ENDPOINT URL",
}).then(function mySuccess(response){
$scope.apiResponse = response.data;
}, function myError(response){
$scope.apiResponse = response.statusText;
});
});
</script>
</head>
<body ng-controller="helloController">
<div>
{{apiResponse}}
</div>
</body>
</html>
</apex:page>