Bonjour,
Je viens de poster sur le forum jboss un problème sur mon authentification est c'est réglé.... du moins quand j'appelle mes webservices en natif par une extention de firefox.
Maintenant quand je passe par angular ça se complique.
Je m'authentifie sur mon serveur et le cookie JSESSIONID généré par mon jboss une fois l'authentification terminée ne se retrouve pas dans les cookies de mon navigateur, alors qu'il apparaît quand je passe par le plugin de firefox.
Donc quand j'accède à un autre webservice (du genre déconnexion) mon jboss ne retrouve pas ma session.
Que faire ?
Voici mon code html :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 <!DOCTYPE html> <html lang="fr" ng-app="app"> <head> <meta charset="utf-8"> <title>Arenapolis</title> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> <link rel="stylesheet" href="css/app.css"> <script src="bower_components/angular/angular.js"></script> <script src="js/app.js"></script> <script src="js/controllers.js"></script> </head> <body> <section> <nav class='navbar navbar-inverse navbar-fixed-top' ²> <ul class="nav navbar-nav"> <li> <a class=h ref="/app">Bâtiments</a> </li> <li> <a class=h ref="/app/cite">Cités</a> </li> <li> <a class=h ref="/app/arene">Arènes</a> </li> </ul> <div ng-controller="connexion-ctrl"> <form class="navbar-form navbar-right " ng-submit="connection()" ) ng-show="donneeConnection==null"> <div class="form-group input-group-sm"> <input placeholder="Courriel" class="form-control" type="email" ng-model="identifiant.userId"> </div> <div class="form-group input-group-sm"> <input placeholder="Mot de passe" class="form-control" type="password" ng-model="identifiant.password"> </div> <button type="submit" class="btn-xs btn-primary">Ok</button> </form> <div ng-show="donneeConnection!=null" class="navbar-form navbar-right "> <button type="button" class="btn-xs btn-primary" ng-click="deconnexion()">deconnexion</button> <span class="label label-inverse form-group" ng-bind="donneeConnection.loginName"/> </div> </div> </nav> </section> </body> </html>
Puis le app.js
Et enfin le controller.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 'use strict'; angular.module('arenaPolis') .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.withCredentials = true; }]);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 'use strict'; var app = angular.module("app", []); app.controller('connexion-ctrl', function ($scope,$http){ $scope.identifiant = { userId : '', password : '' }; $scope.estConnecte = false; $scope.connection = function(){ var promise=$http({ method : 'POST', url : "http://localhost:8080/arenapolis/rs/authentification", headers :{'Content-Type': 'application/x-authc-username-password+json'}, data : $scope.identifiant }); promise.success(function(response){ $scope.donneeConnection=response; $scope.estConnecte = true; $scope.identifiant.userId=null; $scope.identifiant.password=null; }); promise.error(function(response,status){ $scope.erreur=response; $scope.etat=status; $scope.estConnecte = false; }); }; $scope.deconnexion = function(){ var promise=$http({ method : 'POST', url : "http://localhost:8080/arenapolis/rs/deconnexion" }); promise.success(function(response){ $scope.donneeConnection=null; $scope.estConnecte = false; }); promise.error(function(response,status){ $scope.erreur=response; $scope.etat=status; $scope.estConnecte = false; }); }; });
Partager