JWT를위한 최고의 HTTP 인증 헤더 유형
JWT 토큰에 가장 적합한 Authorization
HTTP 헤더 유형 이 무엇인지 궁금합니다 .
아마 가장 인기있는 유형 중 하나는 Basic
입니다. 예를 들어 :
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
로그인 및 비밀번호와 같은 두 가지 매개 변수를 처리합니다. 따라서 JWT 토큰과 관련이 없습니다.
또한 Bearer 유형에 대해 들었습니다 .
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
그러나 나는 그 의미를 모른다. 곰과 관련이 있습니까?
HTTP Authorization
헤더 에서 JWT 토큰을 사용하는 특별한 방법이 있습니까? 우리를 사용해야합니까 Bearer
, 아니면 단순화하고 사용해야합니까?
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
감사.
편집하다:
아니면 JWT
HTTP 헤더 일 수도 있습니다.
JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
클라이언트가 액세스 토큰 (JWT 또는 다른 토큰)을 보내는 데 가장 적합한 HTTP 헤더 Authorization
는 Bearer
인증 체계 가있는 헤더입니다 .
이 체계는 RFC6750에 의해 설명됩니다 .
예:
GET /resource HTTP/1.1 Host: server.example.com Authorization: Bearer eyJhbGciOiJIUzI1NiIXVCJ9...TJVA95OrM7E20RMHrHDcEfxjoYZgeFONFh7HgQ
보다 강력한 보안 보호가 필요한 경우 다음 IETF 초안 ( https://tools.ietf.org/html/draft-ietf-oauth-pop-architecture) 도 고려할 수 있습니다 . 이 초안은 https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac에 대한 좋은 대안으로 보입니다 .
이 RFC 및 위의 사양이 OAuth2 Framework 프로토콜과 관련되어 있어도 클라이언트와 서버 간의 토큰 교환이 필요한 다른 컨텍스트에서 사용할 수 있습니다.
사용자 정의와는 달리 JWT
당신이 당신의 질문에 언급 방식 하나는 IANA에 등록됩니다 .Bearer
Basic
및 Digest
인증 체계 와 관련하여 사용자 이름과 비밀 정보를 사용하는 인증 전용 ( RFC7616 및 RFC7617 참조 )이 해당 컨텍스트에 적용되지 않습니다.
짧은 답변
Bearer
인증 방식은 당신을 위해 무엇을 찾고 있습니다.
긴 대답
곰과 관련이 있습니까?
어 ... 아니요 :)
Oxford Dictionaries 에 따르면 , bearer 의 정의는 다음과 같습니다.
무기명 / ˈbɛːrə /
명사
무언가를 운반하거나 보유하는 사람 또는 사물.
수표 나 돈을 지불하라는 명령을 내린 사람.
첫 번째 정의에는 메신저 , 에이전트 , 컨베이어 , 사절 , 캐리어 , 공급자 동의어가 포함됩니다 .
RFC 6750 에 따른 베어러 토큰 의 정의는 다음과 같습니다.
무기명 토큰
토큰을 소유 한 당사자 ( "소지자")가 소유 한 다른 당사자가 토큰을 소유 할 수있는 속성을 가진 보안 토큰. 베어러 토큰을 사용하면 베어러가 암호화 키 자료 (소지 증명)를 소유하고 있음을 증명할 필요가 없습니다.
The Bearer
authentication scheme is registered in IANA and originally defined in the RFC 6750 for the OAuth 2.0 authorization framework, but nothing stops you from using the Bearer
scheme for access tokens in applications that don't use OAuth 2.0.
Stick to the standards as much as you can and don't create your own authentication schemes.
An access token must be sent in the Authorization
request header using the Bearer
authentication scheme:
2.1. Authorization Request Header Field
When sending the access token in the
Authorization
request header field defined by HTTP/1.1, the client uses theBearer
authentication scheme to transmit the access token.For example:
GET /resource HTTP/1.1 Host: server.example.com Authorization: Bearer mF_9.B5f-4.1JqM
[...]
Clients SHOULD make authenticated requests with a bearer token using the
Authorization
request header field with theBearer
HTTP authorization scheme. [...]
In case of invalid or missing token, the Bearer
scheme should be included in the WWW-Authenticate
response header:
3. The WWW-Authenticate Response Header Field
If the protected resource request does not include authentication credentials or does not contain an access token that enables access to the protected resource, the resource server MUST include the HTTP
WWW-Authenticate
response header field [...].All challenges defined by this specification MUST use the auth-scheme value
Bearer
. This scheme MUST be followed by one or more auth-param values. [...].For example, in response to a protected resource request without authentication:
HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm="example"
And in response to a protected resource request with an authentication attempt using an expired access token:
HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm="example", error="invalid_token", error_description="The access token expired"
참고URL : https://stackoverflow.com/questions/33265812/best-http-authorization-header-type-for-jwt
'Programing' 카테고리의 다른 글
푸시 알림 기술은 Android에서 어떻게 작동합니까? (0) | 2020.05.10 |
---|---|
jq를 사용하여 내부 배열의 값을 기반으로 객체 배열을 필터링하는 방법은 무엇입니까? (0) | 2020.05.10 |
ng-click에서 원본 요소 가져 오기 (0) | 2020.05.10 |
웹 사이트에서 IE9가 호환 모드로 전환되는 이유는 무엇입니까? (0) | 2020.05.10 |
AngularJS 컨트롤러가 동일한 모듈의 다른 컨트롤러에서 상속 할 수 있습니까? (0) | 2020.05.10 |