-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor : Token 만료 시간을 포함한 Property를 TokenPropertyHolder를 통해 객체로 의존성…
… 역전하여 관리 (#112)
- Loading branch information
Showing
16 changed files
with
138 additions
and
81 deletions.
There are no files selected for viewing
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
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
16 changes: 0 additions & 16 deletions
16
src/main/java/gdsc/binaryho/imhere/security/jwt/ImhereSecretHolder.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/main/java/gdsc/binaryho/imhere/security/jwt/ImhereTokenPropertyHolder.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,33 @@ | ||
package gdsc.binaryho.imhere.security.jwt; | ||
|
||
import java.time.Duration; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ImhereTokenPropertyHolder implements TokenPropertyHolder { | ||
|
||
@Value("${token.secret}") | ||
private String secret; | ||
|
||
@Value("${token.access-token-expire-minute}") | ||
private Integer accessTokenExpireMinute; | ||
|
||
@Value("${token.access-token-prefix}") | ||
private String accessTokenPrefix; | ||
|
||
@Override | ||
public String getSecret() { | ||
return secret; | ||
} | ||
|
||
@Override | ||
public Duration getAccessTokenExpiration() { | ||
return Duration.ofMinutes(accessTokenExpireMinute); | ||
} | ||
|
||
@Override | ||
public String getAccessTokenPrefix() { | ||
return accessTokenPrefix; | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
src/main/java/gdsc/binaryho/imhere/security/jwt/SecretHolder.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/gdsc/binaryho/imhere/security/jwt/TokenPropertyHolder.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,12 @@ | ||
package gdsc.binaryho.imhere.security.jwt; | ||
|
||
import java.time.Duration; | ||
|
||
public interface TokenPropertyHolder { | ||
|
||
String getSecret(); | ||
|
||
Duration getAccessTokenExpiration(); | ||
|
||
String getAccessTokenPrefix(); | ||
} |
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
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
31 changes: 31 additions & 0 deletions
31
src/test/java/gdsc/binaryho/imhere/mock/FakeTokenPropertyHolder.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,31 @@ | ||
package gdsc.binaryho.imhere.mock; | ||
|
||
import gdsc.binaryho.imhere.security.jwt.TokenPropertyHolder; | ||
import java.time.Duration; | ||
|
||
public class FakeTokenPropertyHolder implements TokenPropertyHolder { | ||
|
||
private final String secret; | ||
private final Duration accessTokenExpiration; | ||
|
||
|
||
public FakeTokenPropertyHolder(String secret, Duration accessTokenExpiration) { | ||
this.secret = secret; | ||
this.accessTokenExpiration = accessTokenExpiration; | ||
} | ||
|
||
@Override | ||
public String getSecret() { | ||
return secret; | ||
} | ||
|
||
@Override | ||
public Duration getAccessTokenExpiration() { | ||
return accessTokenExpiration; | ||
} | ||
|
||
@Override | ||
public String getAccessTokenPrefix() { | ||
return "prefix"; | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
src/test/java/gdsc/binaryho/imhere/mock/TestSecretHolder.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.