kotlin-jwt

JWT creation library for Kotlin

Лицензия

Лицензия

Категории

Категории

Kotlin Языки программирования
Группа

Группа

com.brendangoldberg
Идентификатор

Идентификатор

kotlin-jwt
Последняя версия

Последняя версия

1.3.1
Дата

Дата

Тип

Тип

pom.sha512
Описание

Описание

kotlin-jwt
JWT creation library for Kotlin
Ссылка на сайт

Ссылка на сайт

https://github.com/brendangoldberg/kotlin-jwt
Система контроля версий

Система контроля версий

https://github.com/brendangoldberg/kotlin-jwt

Скачать kotlin-jwt

Зависимости

runtime (2)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.30
org.jetbrains.kotlinx : kotlinx-serialization-json-jvm jar 1.1.0

Модули Проекта

Данный проект не имеет модулей.

Kotlin JWT Library

License

This is a JSON Web Token (JWT) library written fully in Kotlin utilizing Kotlin Serializer.

For introduction to JWTs please visit https://jwt.io/introduction/.

Features

Examples

import com.brendangoldberg.kotlin_jwt.KtJwtCreator
import com.brendangoldberg.kotlin_jwt.KtJwtDecoder
import com.brendangoldberg.kotlin_jwt.KtJwtVerifier
import com.brendangoldberg.kotlin_jwt.algorithms.HSAlgorithm
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class CustomClaim(
    @SerialName("my_custom_value") val customValue: String
)

fun main() {
    // Declare which signing algorithm to use see import com.brendangoldberg.kotlin_jwt.algorithms.* for available algorithms.
    val algorithm = HSAlgorithm.HS256("my-super-secret")

    val customClaim = CustomClaim("myCustomClaim")

    // Create JWT
    val jwt = KtJwtCreator.init().addClaim("custom_claim", customClaim, CustomClaim.serializer()).sign(algorithm)

    // Verify JWT
    val verified = KtJwtVerifier(algorithm).verify(jwt)

    println("verified: $verified")

    // Decode JWT
    val decoded = KtJwtDecoder.decode(jwt)

    println("custom claim: ${decoded.getClaim("custom_claim", CustomClaim.serializer())}")
}

Setup

Gradle

All versions can be found in the maven repo, or maven search.

repositories { 
  mavenCentral()
}

dependencies {
  implementation("com.brendangoldberg.kotlin-jwt:<latest-version>")

}

Версии библиотеки

Версия
1.3.1
1.3.0
1.2.0