Iam trying to authenticate from Angular2.1.0 to JAAS form-based j2ee app on WildFly 8.2
let j_username = 'sb2'; let j_password = 'sb222'; let url: string = 'http://127.0.0.1:8888/prototype-rest/j_security_check'; let body = 'j_username=' + j_username + '&j_password=' + j_password; let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }) ; //let options = new RequestOptions({headers: headers, withCredentials : true}); let options = new RequestOptions({headers: headers}); this.http.post(url, body, options) .subscribe( (res: Response) => { console.log('res = ' + res); console.log(res.headers.keys()); var headers = res.headers; var setCookieHeader = headers.get('Set-Cookie'); console.log('setCookieHeader = ' + setCookieHeader); }, err => { console.log('err = ' + err); } ) ;
response from wildfly
HTTP/1.1 200 OK Expires: 0 Cache-Control: no-cache, no-store, must-revalidate X-Powered-By: Undertow/1 Set-Cookie: JSESSIONID=iyD6Yz_Tj7xsIM1zRDHaR2bh.sk-za-04702; path=/prototype-rest Access-Control-Allow-Headers: accept, authorization, content-type, x-requested-with Server: WildFly/8 Pragma: no-cache Access-Control-Expose-Headers: Set-Cookie Date: Thu, 03 Nov 2016 14:01:41 GMT Connection: keep-alive Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Content-Length: 0 Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT Access-Control-Max-Age: 3600
My problem is that I am not able to read Set-Cookie, if I use withCredentials : true (I am not sure if I should), response fails ... I'd like to add JSESSIONID to request, where I register websocket ...