Programing

JWT를위한 최고의 HTTP 인증 헤더 유형

lottogame 2020. 5. 10. 10:15
반응형

JWT를위한 최고의 HTTP 인증 헤더 유형


JWT 토큰에 가장 적합한 AuthorizationHTTP 헤더 유형 이 무엇인지 궁금합니다 .

아마 가장 인기있는 유형 중 하나는 Basic입니다. 예를 들어 :

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

로그인 및 비밀번호와 같은 두 가지 매개 변수를 처리합니다. 따라서 JWT 토큰과 관련이 없습니다.

또한 Bearer 유형에 대해 들었습니다 .

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

그러나 나는 그 의미를 모른다. 곰과 관련이 있습니까?

HTTP Authorization헤더 에서 JWT 토큰을 사용하는 특별한 방법이 있습니까? 우리를 사용해야합니까 Bearer, 아니면 단순화하고 사용해야합니까?

Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

감사.

편집하다:

아니면 JWTHTTP 헤더 일 수도 있습니다.

JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

클라이언트가 액세스 토큰 (JWT 또는 다른 토큰)을 보내는 데 가장 적합한 HTTP 헤더 AuthorizationBearer인증 체계 가있는 헤더입니다 .

이 체계는 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

BasicDigest인증 체계 관련하여 사용자 이름과 비밀 정보를 사용하는 인증 전용 ( RFC7616RFC7617 참조 )이 해당 컨텍스트에 적용되지 않습니다.


짧은 답변

Bearer인증 방식은 당신을 위해 무엇을 찾고 있습니다.

긴 대답

곰과 관련이 있습니까?

어 ... 아니요 :)

Oxford Dictionaries 에 따르면 , bearer 의 정의는 다음과 같습니다.

무기명 / ˈbɛːrə /
명사

  1. 무언가를 운반하거나 보유하는 사람 또는 사물.

  2. 수표 나 돈을 지불하라는 명령을 내린 사람.

첫 번째 정의에는 메신저 , 에이전트 , 컨베이어 , 사절 , 캐리어 , 공급자 동의어가 포함됩니다 .

RFC 6750 에 따른 베어러 토큰 의 정의는 다음과 같습니다.

1.2. 술어

무기명 토큰

토큰을 소유 한 당사자 ( "소지자")가 소유 한 다른 당사자가 토큰을 소유 할 수있는 속성을 가진 보안 토큰. 베어러 토큰을 사용하면 베어러가 암호화 키 자료 (소지 증명)를 소유하고 있음을 증명할 필요가 없습니다.

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 the Bearer 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 the Bearer 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

반응형