Skip to content

Commit

Permalink
[auth] app name auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Noverish committed May 5, 2024
1 parent c9159ad commit ff2f1c3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ data class TokenPayload(
val idNo: String,
val username: String,
val authorities: List<String>,
val profile: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import java.util.Date
class TokenService(
private val tokenProperties: TokenProperties,
private val userAuthService: UserAuthService,
private val profileService: ProfileService,
) {
companion object {
const val PAYLOAD_FIELD = "payload"
Expand All @@ -35,7 +34,6 @@ class TokenService(
idNo = user.idNo,
username = user.username,
authorities = userAuthService.getAuthorities(user.idNo),
profile = profileService.getImagePath(user.idNo),
)

return Jwts.builder()
Expand Down
3 changes: 3 additions & 0 deletions hyunsub-auth/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ server.port=7001

logging.file.path=./logs/hyunsub_auth.log

app.name=auth
app.check-authority=false

kms.properties.token=token.key,token.private
kms.properties.captcha=captcha.secretKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ data class AppProperties(
val name: String,
val host: String,
val useAuth: Boolean = true,
val checkAuthority: Boolean = true,
)
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ class UserAuthInterceptor(
}

// Check service authority
checkAuthorityWithAnnotation(userAuth, Authorized(arrayOf(appProperties.name)))
if (appProperties.checkAuthority) {
checkAuthorityWithAnnotation(userAuth, Authorized(arrayOf(appProperties.name)))
}
} catch (ex: ErrorCodeException) {
log.warn { "[Authority] $path - No Authority: authorities=${userAuth.names}" }
throw ex
Expand Down

0 comments on commit ff2f1c3

Please sign in to comment.