-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from 1223v/auth
Fix: Oauth password 추가
- Loading branch information
Showing
3 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/main/java/com/readyvery/readyverydemo/security/jwt/config/JwtConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.readyvery.readyverydemo.security.jwt.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.auth0.jwt.algorithms.Algorithm; | ||
|
||
import lombok.Getter; | ||
|
||
@Configuration | ||
@Getter | ||
public class JwtConfig { | ||
|
||
private String secretKey; | ||
private Long accessTokenExpirationPeriod; | ||
private Long refreshTokenExpirationPeriod; | ||
private Algorithm algorithm; | ||
|
||
private String accessTokenName; | ||
private String refreshTokenName; | ||
private String frontendUrl; | ||
private String cookieDomain; | ||
|
||
public static final String ACCESS_TOKEN_SUBJECT = "AccessToken"; | ||
public static final String REFRESH_TOKEN_SUBJECT = "RefreshToken"; | ||
public static final String EMAIL_CLAIM = "email"; | ||
public static final String USER_NUMBER = "userNumber"; | ||
|
||
@Value("${jwt.secretKey}") | ||
public void setSecretKey(String secretKey) { | ||
this.secretKey = secretKey; | ||
initializeAlgorithm(); | ||
} | ||
|
||
@Value("${jwt.access.expiration}") | ||
public void setAccessTokenExpirationPeriod(Long accessTokenExpirationPeriod) { | ||
this.accessTokenExpirationPeriod = accessTokenExpirationPeriod; | ||
} | ||
|
||
@Value("${jwt.refresh.expiration}") | ||
public void setRefreshTokenExpirationPeriod(Long refreshTokenExpirationPeriod) { | ||
this.refreshTokenExpirationPeriod = refreshTokenExpirationPeriod; | ||
} | ||
|
||
@Value("${jwt.access.cookie}") | ||
public void setAccessTokenName(String accessTokenName) { | ||
this.accessTokenName = accessTokenName; | ||
} | ||
|
||
@Value("${jwt.refresh.cookie}") | ||
public void setRefreshTokenName(String refreshTokenName) { | ||
this.refreshTokenName = refreshTokenName; | ||
} | ||
|
||
@Value("${jwt.redirect-uri}") | ||
public void setFrontendUrl(String frontendUrl) { | ||
this.frontendUrl = frontendUrl; | ||
} | ||
|
||
@Value("${jwt.refresh.cookie.domain}") | ||
public void setCookieDomain(String cookieDomain) { | ||
this.cookieDomain = cookieDomain; | ||
} | ||
|
||
private void initializeAlgorithm() { | ||
if (secretKey != null && !secretKey.isEmpty()) { | ||
algorithm = Algorithm.HMAC512(secretKey); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters