Commit 863081af authored by Ghitha Dinan's avatar Ghitha Dinan

json format fixing

parent 0ab37363
package id.co.sangkuriang.inovasi.daerah.master.config
import id.co.sangkuriang.inovasi.daerah.master.constant.TOKEN_FILTER_PATTERNS
import id.co.sangkuriang.inovasi.daerah.master.constant.USER_ADMIN_ALLOWED_PATH
import id.co.sangkuriang.inovasi.daerah.master.interceptor.TokenInterceptor
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
......@@ -24,7 +24,7 @@ class SpringWebConfig : WebMvcConfigurer {
fun tokenFilter(): FilterRegistrationBean<TokenInterceptor>? {
val registrationBean: FilterRegistrationBean<TokenInterceptor> =
FilterRegistrationBean<TokenInterceptor>()
TOKEN_FILTER_PATTERNS.forEach {
USER_ADMIN_ALLOWED_PATH.forEach {
registrationBean.addUrlPatterns("/$it/*")
}
registrationBean.filter = TokenInterceptor()
......
......@@ -3,11 +3,20 @@ package id.co.sangkuriang.inovasi.daerah.master.constant
const val SECRET = "INOVASI-DAERAH"
const val TOKEN_PREFIX = "Bearer "
const val HEADER_STRING = "Authorization"
val TOKEN_FILTER_PATTERNS =
const val AUTH_URL = "https://auth.inovasi-daerah.spbe.sangkuriang.co.id/auth"
val USER_ALLOWED_PATH = emptyList<String>()
val USER_ADMIN_ALLOWED_PATH =
listOf(
"tag",
"application-category",
"province",
"regency",
"tag"
"/tag/*",
"/application-category/*",
"/province/*",
"/regency/*",
"/tag/*"
)
val AUDIENCE_FILTER_PATH = mapOf(
"user" to USER_ALLOWED_PATH,
"user-admin" to USER_ADMIN_ALLOWED_PATH
)
......@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import id.co.sangkuriang.inovasi.daerah.master.constant.HEADER_STRING
import id.co.sangkuriang.inovasi.daerah.master.constant.SECRET
import id.co.sangkuriang.inovasi.daerah.master.constant.TOKEN_PREFIX
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_NOT_FOUND
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.utility.getPathUrl
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
......@@ -44,6 +45,9 @@ class TokenInterceptor : Filter {
try {
authentication = getAuthentication(req)
if (authentication == null) {
responseException(res, "User $VALIDATOR_MSG_NOT_FOUND")
}
} catch (e: JWTDecodeException) {
successAuth = false
responseException(res, e.message.toString())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment