-
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.
Merge branch 'apply-annotation-processer' into develop
- Loading branch information
Showing
7 changed files
with
51 additions
and
4 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
6 changes: 6 additions & 0 deletions
6
...m/info/maeumgagym/security/authentication/checker/AnnotationBasedAuthenticationChecker.kt
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,6 @@ | ||
package com.info.maeumgagym.security.authentication.checker | ||
|
||
interface AnnotationBasedAuthenticationChecker { | ||
|
||
fun checkAuthentication(annotations: List<Annotation>) | ||
} |
15 changes: 15 additions & 0 deletions
15
...fo/maeumgagym/security/authentication/checker/AnnotationBasedAuthenticationCheckerImpl.kt
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,15 @@ | ||
package com.info.maeumgagym.security.authentication.checker | ||
|
||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AnnotationBasedAuthenticationCheckerImpl( | ||
private val requireAuthenticationChecker: RequireAuthenticationChecker, | ||
private val requireRoleChecker: RequireRoleChecker | ||
) : AnnotationBasedAuthenticationChecker { | ||
|
||
override fun checkAuthentication(annotations: List<Annotation>) { | ||
requireAuthenticationChecker.preProcessing(annotations) | ||
requireRoleChecker.preProcessing(annotations) | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/info/maeumgagym/security/authentication/resolver/UserArgumentResolver.kt
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,28 @@ | ||
package com.info.maeumgagym.security.authentication.resolver | ||
|
||
import com.info.maeumgagym.core.auth.port.out.ReadCurrentUserPort | ||
import com.info.maeumgagym.core.user.model.User | ||
import com.info.maeumgagym.infrastructure.processor.annotation.WebAdapterMethodArgumentAnnotationProcessor | ||
import com.info.maeumgagym.security.authentication.checker.AnnotationBasedAuthenticationChecker | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class UserArgumentResolver( | ||
private val annotationBasedAuthenticationChecker: AnnotationBasedAuthenticationChecker, | ||
private val readCurrentUserPort: ReadCurrentUserPort | ||
) : WebAdapterMethodArgumentAnnotationProcessor { | ||
|
||
override fun <T> supports(type: Class<T>, annotations: List<Annotation>): Boolean = | ||
type == User::class.java | ||
|
||
override fun <T> processing(type: Class<T>, annotations: List<Annotation>): T { | ||
|
||
if (type != User::class.java) { | ||
throw RuntimeException() | ||
} | ||
|
||
annotationBasedAuthenticationChecker.checkAuthentication(annotations) | ||
|
||
return readCurrentUserPort.readCurrentUser() as T | ||
} | ||
} |