Recently, I delved into Rest services in Spring and learned from a tutorial that sending parameters to the backend can be done securely through the following method:
getCompanyDetails(username:string): Observable<CompanyObject>{
const headers = new HttpHeaders({Authorization: 'Basic '+btoa(username)})
return this.http.get<CompanyObject>("http://localhost:8080/company/getCompany",{headers:headers});
}
I am now seeking assistance on how to extract the username at the backend. Although my code successfully reads the "authorization" part, the username remains encoded. Is there a direct way to access this username? Below is my backend code for reference. Thank you.
@GetMapping("company/getCompany")
private void getCompany(@RequestHeader("authorization") HttpHeaders header){
System.out.println(header);
}