diff --git a/src/main/kotlin/com/hrv/mart/apigatewayadmin/config/jwt/JwtAuthenticationManager.kt b/src/main/kotlin/com/hrv/mart/apigatewayadmin/config/jwt/JwtAuthenticationManager.kt index 981df23..a2c3435 100644 --- a/src/main/kotlin/com/hrv/mart/apigatewayadmin/config/jwt/JwtAuthenticationManager.kt +++ b/src/main/kotlin/com/hrv/mart/apigatewayadmin/config/jwt/JwtAuthenticationManager.kt @@ -1,6 +1,6 @@ package com.hrv.mart.apigatewayadmin.config.jwt -import com.hrv.mart.apigatewayadmin.service.JWTService +import com.hrv.mart.apigatewayadmin.service.jwt.JWTService import org.springframework.security.authentication.ReactiveAuthenticationManager import org.springframework.security.authentication.UsernamePasswordAuthenticationToken import org.springframework.security.core.Authentication diff --git a/src/main/kotlin/com/hrv/mart/apigatewayadmin/controller/AuthController.kt b/src/main/kotlin/com/hrv/mart/apigatewayadmin/controller/AuthController.kt index 76293b2..4ae72c6 100644 --- a/src/main/kotlin/com/hrv/mart/apigatewayadmin/controller/AuthController.kt +++ b/src/main/kotlin/com/hrv/mart/apigatewayadmin/controller/AuthController.kt @@ -1,7 +1,7 @@ package com.hrv.mart.apigatewayadmin.controller import com.hrv.mart.apigatewayadmin.service.AuthService -import com.hrv.mart.apigatewayadmin.service.JWTService +import com.hrv.mart.apigatewayadmin.service.jwt.JWTService import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.server.reactive.ServerHttpResponse import org.springframework.web.bind.annotation.PostMapping diff --git a/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/AuthService.kt b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/AuthService.kt index 0ee5551..1095700 100644 --- a/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/AuthService.kt +++ b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/AuthService.kt @@ -1,5 +1,6 @@ package com.hrv.mart.apigatewayadmin.service +import com.hrv.mart.apigatewayadmin.service.jwt.JWTEnhancer import com.hrv.mart.authlibrary.repository.AuthRepository import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.server.reactive.ServerHttpResponse @@ -15,7 +16,7 @@ class AuthService ( fun login(appwriteJWT: String, response: ServerHttpResponse) = authRepository .createAdminAuth( - jwt = appwriteJWT.replace(specialCharCode.toChar().toString(), ""), + jwt = JWTEnhancer.enhanceJWT(appwriteJWT), response = response ) } \ No newline at end of file diff --git a/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTEnhancer.kt b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTEnhancer.kt new file mode 100644 index 0000000..3c5b558 --- /dev/null +++ b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTEnhancer.kt @@ -0,0 +1,10 @@ +package com.hrv.mart.apigatewayadmin.service.jwt + +class JWTEnhancer { + + companion object { + private const val specialCharCode= 34 + fun enhanceJWT(jwt: String) = + jwt.replace(specialCharCode.toChar().toString(), "") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/JWTService.kt b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTService.kt similarity index 93% rename from src/main/kotlin/com/hrv/mart/apigatewayadmin/service/JWTService.kt rename to src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTService.kt index 305d34c..7cc44eb 100644 --- a/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/JWTService.kt +++ b/src/main/kotlin/com/hrv/mart/apigatewayadmin/service/jwt/JWTService.kt @@ -1,4 +1,4 @@ -package com.hrv.mart.apigatewayadmin.service +package com.hrv.mart.apigatewayadmin.service.jwt import io.jsonwebtoken.Jwts import io.jsonwebtoken.SignatureAlgorithm @@ -47,6 +47,6 @@ class JWTService ( Jwts.parserBuilder() .setSigningKey(keyPair.public) .build() - .parseClaimsJws(jwt) + .parseClaimsJws(JWTEnhancer.enhanceJWT(jwt)) } \ No newline at end of file