/tessere
uso del metodo authenticate per la verifica della validità del JWT
This commit is contained in:
parent
728eca6dd6
commit
8e417f02f2
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
|
||||||
}
|
}
|
||||||
rootProject.name = "Backend_API"
|
rootProject.name = "Backend_API_DSU"
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ object ParametriTable : IdTable<Int>("parametri"){
|
|||||||
override val primaryKey = PrimaryKey(id)
|
override val primaryKey = PrimaryKey(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
object TessereTable : IdTable<Int>("tessere"){
|
object TessereTable : IdTable<Int>("view_tessere_api"){
|
||||||
override val id = integer("id").entityId()
|
override val id = integer("id").entityId()
|
||||||
val idUtente = integer("id_utente")
|
val idUtente = integer("id_utente")
|
||||||
val codiceFiscale = varchar("codice_fiscale", 255)
|
val codiceFiscale = varchar("codice_fiscale", 255)
|
||||||
|
@ -6,7 +6,9 @@ package eu.maiora.plugins
|
|||||||
//import eu.maiora.routes.logScriptRouting
|
//import eu.maiora.routes.logScriptRouting
|
||||||
import eu.maiora.model.AccountsRepositoryImpl
|
import eu.maiora.model.AccountsRepositoryImpl
|
||||||
import eu.maiora.model.ParametriRepositoryImpl
|
import eu.maiora.model.ParametriRepositoryImpl
|
||||||
|
import eu.maiora.model.TessereRepositoryImpl
|
||||||
import eu.maiora.routes.auth
|
import eu.maiora.routes.auth
|
||||||
|
import eu.maiora.routes.tessere
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
@ -19,5 +21,6 @@ fun Application.configureRouting(dbUrl : String, username : String, password : S
|
|||||||
}
|
}
|
||||||
|
|
||||||
auth(AccountsRepositoryImpl())
|
auth(AccountsRepositoryImpl())
|
||||||
|
tessere(TessereRepositoryImpl())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,17 @@
|
|||||||
package eu.maiora.routes
|
package eu.maiora.routes
|
||||||
|
|
||||||
import eu.maiora.model.ParametriRepositoryImpl
|
|
||||||
import eu.maiora.model.TessereRepositoryImpl
|
import eu.maiora.model.TessereRepositoryImpl
|
||||||
import io.jsonwebtoken.Jwts
|
|
||||||
import io.jsonwebtoken.SignatureAlgorithm
|
|
||||||
import io.jsonwebtoken.security.Keys
|
|
||||||
import io.ktor.client.statement.*
|
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.auth.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
fun Route.tessere(tessereRepository: TessereRepositoryImpl, parametriRepository: ParametriRepositoryImpl){
|
fun Route.tessere(tessereRepository: TessereRepositoryImpl){
|
||||||
route("/tessere"){
|
route("/api/tessere"){
|
||||||
|
authenticate("auth-jwt") {
|
||||||
get("{cf}"){
|
get("{cf}"){
|
||||||
//verifica JWT
|
|
||||||
val parametro = parametriRepository.parametroByChiave("jwt_secret")
|
|
||||||
if(parametro != null){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ottieni il codice fiscale dal percorso
|
// Ottieni il codice fiscale dal percorso
|
||||||
val cf = call.parameters["cf"]
|
val cf = call.parameters["cf"]
|
||||||
|
|
||||||
@ -45,4 +30,6 @@ fun Route.tessere(tessereRepository: TessereRepositoryImpl, parametriRepository:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user