Share
Sign In

Refresh token, Access token, Sliding Sessions

Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.
Sliding Sessions 전략 및 Access Token
주로 유효한 AccessToken을 가진 클라이언트의 요청에 대해 서버가 새로운 AccessToken을 발급해주는 방법을 사용.
클라이언트가 토큰의 iat(토큰 발급 시간)속성을 참조해서 갱신 요청
장점
사용자가 로그인을 자주 할 필요가 없다.
글을 작성하거나 결제하는 등의 세션 유지가 필요한 경우 만료되는 문제를 방지할 수 있다.
단점
접속이 주로 단발성으로 이루어진 경우 Sliding Session 전략의 효과가 크지 않다.
긴 만료시간을 갖는 A Token의 경우, 로그인을 하지 않아도 되는 경우가 빈번히 발생한다.
Access Token과 Refresh Token 사용
짧은 A Token과 함께 비교적 긴 Refresh Token(이하 R Token)을 발급한다.
A Token은 30분 내외, R Token은 2주 ~ 한달 정도로 만료기간을 부여한다.
AccessToken이 만료되었다는 오류를 받으면 따로 저장해두었던 RefreshToken을 이용하여 AccessToken의 재발급을 요청합니다. 서버는 유효한 RefreshToken으로 요청이 들어오면 새로운 AccessToken을 발급하고, 만료된 RefreshToken으로 요청이 들어오면 오류를 반환해, 사용자에게 로그인을 요구합니다.
장점
짧은 만료 기간을 사용할 수 있어 Access Token이 탈취되더라도 제한 기간 없이 접근이 가능
사용자가 로그인을 자주 할 필요 없음
R Token을 강제로 만료할 수 있다.
단점
클라이언트에서 Access Token의 만료에 대한 연장 요청을 구현해야한다.
인증 만료 기간의 자동 연장이 불가능 하다.
access token과 refresh token 모두 만료 ⇒ 에러 발생, 재 로그인하여 둘다 새로 발급
access token 만료, refresh token 유효 ⇒ refresh 검증 후 A token 재발급, R token 업데이트
유효 refresh token 검증
refresh token = user 타당성 검증
Flow
1.
Token Validation: The backend should validate the refresh token by checking if it has been revoked or if it has expired. If the refresh token is invalid, the backend should return an error to the client and the client should request a new access token by re-authenticating the user.
2.
Generation of a New Access Token: If the refresh token is valid, the backend should generate a new access token. This token should have a new expiration time and a new token value.
3.
Update of the Refresh Token: The backend should update the refresh token with a new value and a new expiration time. This helps ensure that the refresh token can only be used once and helps prevent replay attacks.
4.
Response to the Client: The backend should return the new access token and the updated refresh token to the client. The client can then use the new access token for future API requests.
access token 유효, refresh token 만료 ⇒ A token 을 검증 후, refresh token 재발급
Flow
1.
Token Validation: The backend should validate the access token to ensure that it has not been revoked or tampered with. If the access token is valid, the user remains authenticated and can continue to access the API.
2.
Request for a New Access Token: If the user needs to access a protected resource after the refresh token has expired, the client should make a request to the backend for a new access token.
3.
Re-authentication: The backend should require the user to re-authenticate before issuing a new access token and refresh token. This can involve sending a verification code via SMS or email, or asking the user to enter their username and password.
4.
Generation of a New Access Token and Refresh Token: After the user has re-authenticated, the backend should generate a new access token and refresh token with new expiration times and new token values.
5.
Response to the Client: The backend should return the new access token and refresh token to the client, which can then be used for future API requests.
access token 유효, refresh token 유효 ⇒ 정상처리
Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.
Sliding Sessions 전략 및 Access Token
주로 유효한 AccessToken을 가진 클라이언트의 요청에 대해 서버가 새로운 AccessToken을 발급해주는 방법을 사용.
클라이언트가 토큰의 iat(토큰 발급 시간)속성을 참조해서 갱신 요청
장점
사용자가 로그인을 자주 할 필요가 없다.
글을 작성하거나 결제하는 등의 세션 유지가 필요한 경우 만료되는 문제를 방지할 수 있다.
단점
접속이 주로 단발성으로 이루어진 경우 Sliding Session 전략의 효과가 크지 않다.
긴 만료시간을 갖는 A Token의 경우, 로그인을 하지 않아도 되는 경우가 빈번히 발생한다.
Access Token과 Refresh Token 사용
짧은 A Token과 함께 비교적 긴 Refresh Token(이하 R Token)을 발급한다.
A Token은 30분 내외, R Token은 2주 ~ 한달 정도로 만료기간을 부여한다.
AccessToken이 만료되었다는 오류를 받으면 따로 저장해두었던 RefreshToken을 이용하여 AccessToken의 재발급을 요청합니다. 서버는 유효한 RefreshToken으로 요청이 들어오면 새로운 AccessToken을 발급하고, 만료된 RefreshToken으로 요청이 들어오면 오류를 반환해, 사용자에게 로그인을 요구합니다.
장점
짧은 만료 기간을 사용할 수 있어 Access Token이 탈취되더라도 제한 기간 없이 접근이 가능
사용자가 로그인을 자주 할 필요 없음
R Token을 강제로 만료할 수 있다.
단점
클라이언트에서 Access Token의 만료에 대한 연장 요청을 구현해야한다.
인증 만료 기간의 자동 연장이 불가능 하다.
access token과 refresh token 모두 만료 ⇒ 에러 발생, 재 로그인하여 둘다 새로 발급
access token 만료, refresh token 유효 ⇒ refresh 검증 후 A token 재발급, R token 업데이트
유효 refresh token 검증
refresh token = user 타당성 검증
Flow
1.
Token Validation: The backend should validate the refresh token by checking if it has been revoked or if it has expired. If the refresh token is invalid, the backend should return an error to the client and the client should request a new access token by re-authenticating the user.
2.
Generation of a New Access Token: If the refresh token is valid, the backend should generate a new access token. This token should have a new expiration time and a new token value.
3.
Update of the Refresh Token: The backend should update the refresh token with a new value and a new expiration time. This helps ensure that the refresh token can only be used once and helps prevent replay attacks.
4.
Response to the Client: The backend should return the new access token and the updated refresh token to the client. The client can then use the new access token for future API requests.
access token 유효, refresh token 만료 ⇒ A token 을 검증 후, refresh token 재발급
Flow
1.
Token Validation: The backend should validate the access token to ensure that it has not been revoked or tampered with. If the access token is valid, the user remains authenticated and can continue to access the API.
2.
Request for a New Access Token: If the user needs to access a protected resource after the refresh token has expired, the client should make a request to the backend for a new access token.
3.
Re-authentication: The backend should require the user to re-authenticate before issuing a new access token and refresh token. This can involve sending a verification code via SMS or email, or asking the user to enter their username and password.
4.
Generation of a New Access Token and Refresh Token: After the user has re-authenticated, the backend should generate a new access token and refresh token with new expiration times and new token values.
5.
Response to the Client: The backend should return the new access token and refresh token to the client, which can then be used for future API requests.
access token 유효, refresh token 유효 ⇒ 정상처리
Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.
Sliding Sessions 전략 및 Access Token
주로 유효한 AccessToken을 가진 클라이언트의 요청에 대해 서버가 새로운 AccessToken을 발급해주는 방법을 사용.
클라이언트가 토큰의 iat(토큰 발급 시간)속성을 참조해서 갱신 요청
장점
사용자가 로그인을 자주 할 필요가 없다.
글을 작성하거나 결제하는 등의 세션 유지가 필요한 경우 만료되는 문제를 방지할 수 있다.
단점
접속이 주로 단발성으로 이루어진 경우 Sliding Session 전략의 효과가 크지 않다.
긴 만료시간을 갖는 A Token의 경우, 로그인을 하지 않아도 되는 경우가 빈번히 발생한다.
Access Token과 Refresh Token 사용
짧은 A Token과 함께 비교적 긴 Refresh Token(이하 R Token)을 발급한다.
A Token은 30분 내외, R Token은 2주 ~ 한달 정도로 만료기간을 부여한다.
AccessToken이 만료되었다는 오류를 받으면 따로 저장해두었던 RefreshToken을 이용하여 AccessToken의 재발급을 요청합니다. 서버는 유효한 RefreshToken으로 요청이 들어오면 새로운 AccessToken을 발급하고, 만료된 RefreshToken으로 요청이 들어오면 오류를 반환해, 사용자에게 로그인을 요구합니다.
장점
짧은 만료 기간을 사용할 수 있어 Access Token이 탈취되더라도 제한 기간 없이 접근이 가능
사용자가 로그인을 자주 할 필요 없음
R Token을 강제로 만료할 수 있다.
단점
클라이언트에서 Access Token의 만료에 대한 연장 요청을 구현해야한다.
인증 만료 기간의 자동 연장이 불가능 하다.
access token과 refresh token 모두 만료 ⇒ 에러 발생, 재 로그인하여 둘다 새로 발급
access token 만료, refresh token 유효 ⇒ refresh 검증 후 A token 재발급, R token 업데이트
유효 refresh token 검증
refresh token = user 타당성 검증
Flow
1.
Token Validation: The backend should validate the refresh token by checking if it has been revoked or if it has expired. If the refresh token is invalid, the backend should return an error to the client and the client should request a new access token by re-authenticating the user.
2.
Generation of a New Access Token: If the refresh token is valid, the backend should generate a new access token. This token should have a new expiration time and a new token value.
3.
Update of the Refresh Token: The backend should update the refresh token with a new value and a new expiration time. This helps ensure that the refresh token can only be used once and helps prevent replay attacks.
4.
Response to the Client: The backend should return the new access token and the updated refresh token to the client. The client can then use the new access token for future API requests.
access token 유효, refresh token 만료 ⇒ A token 을 검증 후, refresh token 재발급
Flow
1.
Token Validation: The backend should validate the access token to ensure that it has not been revoked or tampered with. If the access token is valid, the user remains authenticated and can continue to access the API.
2.
Request for a New Access Token: If the user needs to access a protected resource after the refresh token has expired, the client should make a request to the backend for a new access token.
3.
Re-authentication: The backend should require the user to re-authenticate before issuing a new access token and refresh token. This can involve sending a verification code via SMS or email, or asking the user to enter their username and password.
4.
Generation of a New Access Token and Refresh Token: After the user has re-authenticated, the backend should generate a new access token and refresh token with new expiration times and new token values.
5.
Response to the Client: The backend should return the new access token and refresh token to the client, which can then be used for future API requests.
access token 유효, refresh token 유효 ⇒ 정상처리
Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.
Sliding Sessions 전략 및 Access Token
주로 유효한 AccessToken을 가진 클라이언트의 요청에 대해 서버가 새로운 AccessToken을 발급해주는 방법을 사용.
클라이언트가 토큰의 iat(토큰 발급 시간)속성을 참조해서 갱신 요청
장점
사용자가 로그인을 자주 할 필요가 없다.
글을 작성하거나 결제하는 등의 세션 유지가 필요한 경우 만료되는 문제를 방지할 수 있다.
단점
접속이 주로 단발성으로 이루어진 경우 Sliding Session 전략의 효과가 크지 않다.
긴 만료시간을 갖는 A Token의 경우, 로그인을 하지 않아도 되는 경우가 빈번히 발생한다.
Access Token과 Refresh Token 사용
짧은 A Token과 함께 비교적 긴 Refresh Token(이하 R Token)을 발급한다.
A Token은 30분 내외, R Token은 2주 ~ 한달 정도로 만료기간을 부여한다.
AccessToken이 만료되었다는 오류를 받으면 따로 저장해두었던 RefreshToken을 이용하여 AccessToken의 재발급을 요청합니다. 서버는 유효한 RefreshToken으로 요청이 들어오면 새로운 AccessToken을 발급하고, 만료된 RefreshToken으로 요청이 들어오면 오류를 반환해, 사용자에게 로그인을 요구합니다.
장점
짧은 만료 기간을 사용할 수 있어 Access Token이 탈취되더라도 제한 기간 없이 접근이 가능
사용자가 로그인을 자주 할 필요 없음
R Token을 강제로 만료할 수 있다.
단점
클라이언트에서 Access Token의 만료에 대한 연장 요청을 구현해야한다.
인증 만료 기간의 자동 연장이 불가능 하다.
access token과 refresh token 모두 만료 ⇒ 에러 발생, 재 로그인하여 둘다 새로 발급
access token 만료, refresh token 유효 ⇒ refresh 검증 후 A token 재발급, R token 업데이트
유효 refresh token 검증
refresh token = user 타당성 검증
Flow
1.
Token Validation: The backend should validate the refresh token by checking if it has been revoked or if it has expired. If the refresh token is invalid, the backend should return an error to the client and the client should request a new access token by re-authenticating the user.
2.
Generation of a New Access Token: If the refresh token is valid, the backend should generate a new access token. This token should have a new expiration time and a new token value.
3.
Update of the Refresh Token: The backend should update the refresh token with a new value and a new expiration time. This helps ensure that the refresh token can only be used once and helps prevent replay attacks.
4.
Response to the Client: The backend should return the new access token and the updated refresh token to the client. The client can then use the new access token for future API requests.
access token 유효, refresh token 만료 ⇒ A token 을 검증 후, refresh token 재발급
Flow
1.
Token Validation: The backend should validate the access token to ensure that it has not been revoked or tampered with. If the access token is valid, the user remains authenticated and can continue to access the API.
2.
Request for a New Access Token: If the user needs to access a protected resource after the refresh token has expired, the client should make a request to the backend for a new access token.
3.
Re-authentication: The backend should require the user to re-authenticate before issuing a new access token and refresh token. This can involve sending a verification code via SMS or email, or asking the user to enter their username and password.
4.
Generation of a New Access Token and Refresh Token: After the user has re-authenticated, the backend should generate a new access token and refresh token with new expiration times and new token values.
5.
Response to the Client: The backend should return the new access token and refresh token to the client, which can then be used for future API requests.
access token 유효, refresh token 유효 ⇒ 정상처리
Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.
Sliding Sessions 전략 및 Access Token
주로 유효한 AccessToken을 가진 클라이언트의 요청에 대해 서버가 새로운 AccessToken을 발급해주는 방법을 사용.
클라이언트가 토큰의 iat(토큰 발급 시간)속성을 참조해서 갱신 요청
장점
사용자가 로그인을 자주 할 필요가 없다.
글을 작성하거나 결제하는 등의 세션 유지가 필요한 경우 만료되는 문제를 방지할 수 있다.
단점
접속이 주로 단발성으로 이루어진 경우 Sliding Session 전략의 효과가 크지 않다.
긴 만료시간을 갖는 A Token의 경우, 로그인을 하지 않아도 되는 경우가 빈번히 발생한다.
Access Token과 Refresh Token 사용
짧은 A Token과 함께 비교적 긴 Refresh Token(이하 R Token)을 발급한다.
A Token은 30분 내외, R Token은 2주 ~ 한달 정도로 만료기간을 부여한다.
AccessToken이 만료되었다는 오류를 받으면 따로 저장해두었던 RefreshToken을 이용하여 AccessToken의 재발급을 요청합니다. 서버는 유효한 RefreshToken으로 요청이 들어오면 새로운 AccessToken을 발급하고, 만료된 RefreshToken으로 요청이 들어오면 오류를 반환해, 사용자에게 로그인을 요구합니다.
장점
짧은 만료 기간을 사용할 수 있어 Access Token이 탈취되더라도 제한 기간 없이 접근이 가능
사용자가 로그인을 자주 할 필요 없음
R Token을 강제로 만료할 수 있다.
단점
클라이언트에서 Access Token의 만료에 대한 연장 요청을 구현해야한다.
인증 만료 기간의 자동 연장이 불가능 하다.
access token과 refresh token 모두 만료 ⇒ 에러 발생, 재 로그인하여 둘다 새로 발급
access token 만료, refresh token 유효 ⇒ refresh 검증 후 A token 재발급, R token 업데이트
유효 refresh token 검증
refresh token = user 타당성 검증
Flow
1.
Token Validation: The backend should validate the refresh token by checking if it has been revoked or if it has expired. If the refresh token is invalid, the backend should return an error to the client and the client should request a new access token by re-authenticating the user.
2.
Generation of a New Access Token: If the refresh token is valid, the backend should generate a new access token. This token should have a new expiration time and a new token value.
3.
Update of the Refresh Token: The backend should update the refresh token with a new value and a new expiration time. This helps ensure that the refresh token can only be used once and helps prevent replay attacks.
4.
Response to the Client: The backend should return the new access token and the updated refresh token to the client. The client can then use the new access token for future API requests.
access token 유효, refresh token 만료 ⇒ A token 을 검증 후, refresh token 재발급
Flow
1.
Token Validation: The backend should validate the access token to ensure that it has not been revoked or tampered with. If the access token is valid, the user remains authenticated and can continue to access the API.
2.
Request for a New Access Token: If the user needs to access a protected resource after the refresh token has expired, the client should make a request to the backend for a new access token.
3.
Re-authentication: The backend should require the user to re-authenticate before issuing a new access token and refresh token. This can involve sending a verification code via SMS or email, or asking the user to enter their username and password.
4.
Generation of a New Access Token and Refresh Token: After the user has re-authenticated, the backend should generate a new access token and refresh token with new expiration times and new token values.
5.
Response to the Client: The backend should return the new access token and refresh token to the client, which can then be used for future API requests.
access token 유효, refresh token 유효 ⇒ 정상처리
Access Token 만 사용
짧은 Access Token
장점
기기의 A Token이 탈취되더라도 빠르게 만료 된다.
단점
자주 로그인을 해야한다. 한 사용자가 오랫동안 상주하는 서비스일 경우, 이용하는 도중에 로그아웃 되어버린다.
결제, 게시글 등 시간이 오래걸리는 작업시 인증이 만료되어 버린다.
긴 Access Token
장점
사용자가 자주 로그인 할 필요가 없다.
결제, 게시글 등 시간이 오래 걸리는 작업시 로그인 아웃 당하는 일이 없다.
단점
A Token 탈취 시, 해커 또한 오랫동안 제약없이 사용이 가능하다.