首页 > 解决方案 > 是否有任何解决方案可以从请求标头中隐藏授权或隐藏令牌

问题描述

我正在尝试保护我的网站,我想隐藏授权或只是隐藏令牌。

我正在使用 Angular 7 和 IIS 服务器。

这是我在前端使用我的令牌时:

   var headerOptions = new Headers({
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + this.token,
        'contrat_token': this.contrat_token
    }); 

    let options = new RequestOptions({
        search: params,
        headers: headerOptions
    });

    return this._http.get(url, options).pipe(map(resp => {
        if (resp.status === 401 || resp.status == 401 || resp.status.toString() == "401") {
            this.clearCookie();
        }
        else {
            let reponse = JSON.parse(resp.json());

            if (reponse == -1 || reponse == "-1") {
                this.router.navigate(["/"]);
            }
        }

        return JSON.parse(resp.json())
    }
    ), catchError((error) => {
        if (error.status == 401 || error.status == "401") {
            this.clearCookie();
        }
        return of();
    })
    );

我在请求标头中看到:

     Authorization: Bearer THL8iBl4y4QTMh8sz8UluO3vDbtVib2Axp-_zYcPRGQVesnzDJVdFVq3GsYXeo4znSMbGqKNmLcGL_inNsMWAtc22

我想看到类似的东西:

      Authorization: Bearer ******************

标签: angularauthorizationtokenbearer-tokenrequest-headers

解决方案


推荐阅读