Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
I
Inovasi Daerah Master
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ghitha Dinan
Inovasi Daerah Master
Commits
863081af
Commit
863081af
authored
Oct 07, 2021
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json format fixing
parent
0ab37363
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
SpringWebConfig.kt
...ngkuriang/inovasi/daerah/master/config/SpringWebConfig.kt
+2
-2
SecurityConstant.kt
...uriang/inovasi/daerah/master/constant/SecurityConstant.kt
+15
-6
TokenInterceptor.kt
...ang/inovasi/daerah/master/interceptor/TokenInterceptor.kt
+4
-0
No files found.
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/config/SpringWebConfig.kt
View file @
863081af
package
id.co.sangkuriang.inovasi.daerah.master.config
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
id.co.sangkuriang.inovasi.daerah.master.interceptor.TokenInterceptor
import
org.springframework.boot.web.servlet.FilterRegistrationBean
import
org.springframework.boot.web.servlet.FilterRegistrationBean
import
org.springframework.context.annotation.Bean
import
org.springframework.context.annotation.Bean
...
@@ -24,7 +24,7 @@ class SpringWebConfig : WebMvcConfigurer {
...
@@ -24,7 +24,7 @@ class SpringWebConfig : WebMvcConfigurer {
fun
tokenFilter
():
FilterRegistrationBean
<
TokenInterceptor
>?
{
fun
tokenFilter
():
FilterRegistrationBean
<
TokenInterceptor
>?
{
val
registrationBean
:
FilterRegistrationBean
<
TokenInterceptor
>
=
val
registrationBean
:
FilterRegistrationBean
<
TokenInterceptor
>
=
FilterRegistrationBean
<
TokenInterceptor
>()
FilterRegistrationBean
<
TokenInterceptor
>()
TOKEN_FILTER_PATTERNS
.
forEach
{
USER_ADMIN_ALLOWED_PATH
.
forEach
{
registrationBean
.
addUrlPatterns
(
"/$it/*"
)
registrationBean
.
addUrlPatterns
(
"/$it/*"
)
}
}
registrationBean
.
filter
=
TokenInterceptor
()
registrationBean
.
filter
=
TokenInterceptor
()
...
...
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/constant/SecurityConstant.kt
View file @
863081af
...
@@ -3,11 +3,20 @@ package id.co.sangkuriang.inovasi.daerah.master.constant
...
@@ -3,11 +3,20 @@ package id.co.sangkuriang.inovasi.daerah.master.constant
const
val
SECRET
=
"INOVASI-DAERAH"
const
val
SECRET
=
"INOVASI-DAERAH"
const
val
TOKEN_PREFIX
=
"Bearer "
const
val
TOKEN_PREFIX
=
"Bearer "
const
val
HEADER_STRING
=
"Authorization"
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
(
listOf
(
"
tag
"
,
"
/tag/*
"
,
"
application-category
"
,
"
/application-category/*
"
,
"
province
"
,
"
/province/*
"
,
"
regency
"
,
"
/regency/*
"
,
"
tag
"
"
/tag/*
"
)
)
val
AUDIENCE_FILTER_PATH
=
mapOf
(
"user"
to
USER_ALLOWED_PATH
,
"user-admin"
to
USER_ADMIN_ALLOWED_PATH
)
src/main/kotlin/id/co/sangkuriang/inovasi/daerah/master/interceptor/TokenInterceptor.kt
View file @
863081af
...
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
...
@@ -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.HEADER_STRING
import
id.co.sangkuriang.inovasi.daerah.master.constant.SECRET
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.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.model.response.ReturnData
import
id.co.sangkuriang.inovasi.daerah.master.utility.getPathUrl
import
id.co.sangkuriang.inovasi.daerah.master.utility.getPathUrl
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
...
@@ -44,6 +45,9 @@ class TokenInterceptor : Filter {
...
@@ -44,6 +45,9 @@ class TokenInterceptor : Filter {
try
{
try
{
authentication
=
getAuthentication
(
req
)
authentication
=
getAuthentication
(
req
)
if
(
authentication
==
null
)
{
responseException
(
res
,
"User $VALIDATOR_MSG_NOT_FOUND"
)
}
}
catch
(
e
:
JWTDecodeException
)
{
}
catch
(
e
:
JWTDecodeException
)
{
successAuth
=
false
successAuth
=
false
responseException
(
res
,
e
.
message
.
toString
())
responseException
(
res
,
e
.
message
.
toString
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment