Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1439696

Browse files
committed
JwtSecretKey has been added to the project.
1 parent 2cfbbcc commit 1439696

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.bookstore.api.jwt;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.context.properties.ConfigurationProperties;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.http.HttpHeaders;
7+
8+
import lombok.Data;
9+
10+
@Configuration
11+
@ConfigurationProperties(prefix = "application.jwt")
12+
@Data
13+
public class JwtConfig {
14+
private String secretKey;
15+
private String tokenPrefix;
16+
17+
@Value("${application.jwt.expire.in}")
18+
private Long expireIn;
19+
20+
public String getAuthorizationHeader() {
21+
return HttpHeaders.AUTHORIZATION;
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.bookstore.api.jwt;
2+
3+
import javax.crypto.SecretKey;
4+
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
import io.jsonwebtoken.security.Keys;
9+
10+
@Configuration
11+
public class JwtSecretKey {
12+
private final JwtConfig jwtConfig;
13+
14+
public JwtSecretKey(JwtConfig jwtConfig) {
15+
this.jwtConfig = jwtConfig;
16+
}
17+
18+
@Bean
19+
public SecretKey secretKey(){
20+
return Keys.hmacShaKeyFor(jwtConfig.getSecretKey().getBytes());
21+
}
22+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /