Hi all,

I just setup apache as a proxy in top of grafana. My goal is to log in 
dynamically users in grafana dashboard using basic authentication. First I 
executed a GET request with a Basic Authentication header encoded in base 
64 For instance admin:admin. The response of the request should be embeded 
in a iframe. But I have a little issue. When executing my simple HTML 
script to perform it, I have a {{alert.title}} instead of the grafana home 
page with the user logged in. I have enabled auth.basic in grafana.ini file 
and my basic authentication works. In fact in a browser like 
chrome/chromium with the mod header module. I add my header with the Basic 
token and it works. Here is the HTML script I use (with angularjs of 
course) :

<!DOCTYPE html>
<html lang="en-US">
<meta charset="utf-8" />
<script src=
"http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js";
></script>
<script src="http://requirejs.org/docs/release/2.1.11/minified/require.js";
></script>
<script src="https://code.jquery.com/jquery-1.11.3.js";></script>
<script>
    var app = angular.module('myApp', []);

      app.controller('MainCtrl', function ($scope, $http, $sce) {

    $scope.trustSrc = function(src) {
        console.log(src);
        return $sce.trustAsHtml(src);
    }

    $http({
        method : 'GET',
        url : 'http://mydomain.com',
        headers : {
            'Authorization' : 'Basic YWRisA46YQRtaW4='
        }
                                
    }).success(function(response) {
        console.log(response);
        
        $("#test").attr('src',"data:text/html;charset=utf-8," + escape(
response))
            $("#test").contents().find('html').html(response);

    }).error(function(error) {
        console.log(error);
    });
});
</script>
<body >

<div ng-app="myApp" ng-controller="MainCtrl">

<iframe id="test" style="position: absolute; top: 50px; left: 0px; bottom: 
0px; right: 0px; width: 100%; height: 100%; border: none; margin: 0; padding
: 0; overflow: hidden;"></iframe>


</div>

</body>
</html> 

Can someone help me. If not, how can I Execute a http request inside of a 
iframe. That means if I want to execute a $http request as a src of a 
iframe and the response, as it's a html page will be display corerctly. 
Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to