add tamper protection

This commit is contained in:
gowthaman.b
2023-11-12 09:18:27 +05:30
parent 10813529f2
commit b4a6308d5a
2 changed files with 22 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import io.ebean.config.DatabaseConfig
import io.ebean.config.TenantMode
import org.bouncycastle.openssl.jcajce.JcaPEMWriter
import org.bouncycastle.util.io.pem.PemReader
import org.jose4j.jwk.JsonWebKey
import org.jose4j.jwk.PublicJsonWebKey
import org.jose4j.jwk.RsaJsonWebKey
import org.jose4j.jwk.RsaJwkGenerator
@@ -108,7 +109,7 @@ object Session {
}
fun sign(payload: String): String {
fun signPayload(payload: String): String {
// Create a new JsonWebSignature
val jws = JsonWebSignature()
@@ -161,6 +162,7 @@ object Session {
fun currentUser() = currentUser.get().userName
fun currentTenant() = currentUser.get().tenant
fun currentRoles() = currentUser.get().roles
fun jwk() = keypair.toParams(JsonWebKey.OutputControlLevel.PUBLIC_ONLY)
fun Database.findByEntityAndId(entity: String, id: String): DataModel {
return find(DataModel::class.java)