All Projects → myndocs → kotlin-oauth2-server

myndocs / kotlin-oauth2-server

Licence: Apache-2.0 license
Flexible OAuth2 server library. Support for multiple frameworks

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to kotlin-oauth2-server

obsidian
◼️ A standalone audio sending node for music bots.
Stars: ✭ 22 (-82.11%)
Mutual labels:  ktor
ktor-API-examples
Examples with ktor to create an API REST
Stars: ✭ 23 (-81.3%)
Mutual labels:  ktor
Sheasy
This an Android App that helps you share/manage your files on your Android Device through a WebInterface in the Browser - Built with Ktor and Kotlin-React
Stars: ✭ 34 (-72.36%)
Mutual labels:  ktor
laravel-passport-demo
Shows you how to turn your website to an Oauth2 server using Laravel Passport
Stars: ✭ 27 (-78.05%)
Mutual labels:  oauth2-server
exposed-ktor-jwt
example of an exposed+ktor+jwt secured kotlin app sporting an angular frontend
Stars: ✭ 21 (-82.93%)
Mutual labels:  ktor
sherlock
Sherlock is an anomaly detection service built on top of Druid
Stars: ✭ 137 (+11.38%)
Mutual labels:  sparkjava
ktor-features-zipkin
A Ktor feature that handles Open Zipkin tracing IDs
Stars: ✭ 15 (-87.8%)
Mutual labels:  ktor
kotlin-ktor-mysql-template
This example shows how to run Anychart library with Kotlin and MySQL.
Stars: ✭ 20 (-83.74%)
Mutual labels:  ktor
Taroco-Authentication
Taroco-Authentication 统一认证服务
Stars: ✭ 49 (-60.16%)
Mutual labels:  oauth2-server
ktor-hexagonal-benchmark
a experimental ktor application using hexagonal architecture
Stars: ✭ 32 (-73.98%)
Mutual labels:  ktor
ktfunctional
a functional library for kotlin(android)
Stars: ✭ 19 (-84.55%)
Mutual labels:  ktor
Diber-backend
Delivery Service - Spring Boot / Spring Data Jpa / Hibernate / PostgreSQL / OAuth2 Application
Stars: ✭ 22 (-82.11%)
Mutual labels:  oauth2-server
Sunset-hadith
Islamic app written with Kotlin, using KTOR + coroutines + flow + MVVM + Android Jetpack + Navigation component. Old version using RxJava + Retrofit + OKHttp
Stars: ✭ 26 (-78.86%)
Mutual labels:  ktor
examples
Fully self-contained examples of using the various http4k features
Stars: ✭ 58 (-52.85%)
Mutual labels:  http4k
oauth2
Interface oriented implementation, no coupling with the model and database, support for GC
Stars: ✭ 12 (-90.24%)
Mutual labels:  oauth2-server
MultiplatformPlayground
Kotlin Multiplatform project in Jetpack Compose & SwiftUI with shared ViewModel layer and File upload
Stars: ✭ 72 (-41.46%)
Mutual labels:  ktor
heterogeneous-microservices
Implementation of the same simple microservice on different frameworks
Stars: ✭ 43 (-65.04%)
Mutual labels:  ktor
kmpapp
👨‍💻 Kotlin Mobile Multiplatform App (Android & iOS). One Code To Rule Them All. MVVM, DI (Kodein), coroutines, livedata, ktor, serialization, mockk, detekt, ktlint, jacoco
Stars: ✭ 34 (-72.36%)
Mutual labels:  ktor
avaje-http
Controller generation for Javalin, Helidon SE.
Stars: ✭ 23 (-81.3%)
Mutual labels:  javalin
tv-maniac
Tv-Maniac is a Multiplatform app (Android & iOS) for viewing TV Shows from TMDB.
Stars: ✭ 55 (-55.28%)
Mutual labels:  ktor

Kotlin OAuth2 server

Goal

The goal of this project is to provide a simple OAuth2 library which can be implemented in any framework

Configuring the oauth2 server for any framework should be simple and understandable. It encourages to adapt to existing implementations instead the other way around.

Frameworks

Setup

Maven

<properties>
    <myndocs.oauth.version>0.7.1</myndocs.oauth.version>
</properties>

<dependencies>
    <dependency>
        <groupId>nl.myndocs</groupId>
        <artifactId>oauth2-server-core</artifactId>
        <version>${myndocs.oauth.version}</version>
    </dependency>
    
    <!-- In memory dependencies -->
    <dependency>
        <groupId>nl.myndocs</groupId>
        <artifactId>oauth2-server-client-inmemory</artifactId>
        <version>${myndocs.oauth.version}</version>
    </dependency>
    <dependency>
        <groupId>nl.myndocs</groupId>
        <artifactId>oauth2-server-identity-inmemory</artifactId>
        <version>${myndocs.oauth.version}</version>
    </dependency>
    <dependency>
        <groupId>nl.myndocs</groupId>
        <artifactId>oauth2-server-token-store-inmemory</artifactId>
        <version>${myndocs.oauth.version}</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    implementation "nl.myndocs:oauth2-server-core:$myndocs_oauth_version"
    // In memory dependencies
    implementation "nl.myndocs:oauth2-server-client-inmemory:$myndocs_oauth_version"
    implementation "nl.myndocs:oauth2-server-identity-inmemory:$myndocs_oauth_version"
    implementation "nl.myndocs:oauth2-server-token-store-inmemory:$myndocs_oauth_version"
}

Framework implementation

The following frameworks are supported:

Configuration

Routing

Default endpoints are configured:

Type Relative url
token /oauth/token
authorize /oauth/authorize
token info /oauth/tokeninfo

These values can be overridden:

tokenEndpoint = "/custom/token"
authorizationEndpoint = "/custom/authorize"
tokenInfoEndpoint = "/custom/tokeninfo"

In memory

In memory implementations are provided to easily setup the project.

Identity

On the InMemoryIdentity identities can be registered. These are normally your users:

identityService = InMemoryIdentity()
    .identity {
        username = "foo-1"
        password = "bar"
    }
    .identity {
        username = "foo-2"
        password = "bar"
    }

Client

On the InMemoryClient clients can be registered:

clientService = InMemoryClient()
    .client {
        clientId = "app1-client"
        clientSecret = "testpass"
        scopes = setOf("admin")
        redirectUris = setOf("https://localhost:8080/callback")
        authorizedGrantTypes = setOf(
                AuthorizedGrantType.AUTHORIZATION_CODE,
                AuthorizedGrantType.PASSWORD,
                AuthorizedGrantType.IMPLICIT,
                AuthorizedGrantType.REFRESH_TOKEN
        )
    }
    .client {
            clientId = "app2-client"
            clientSecret = "testpass"
            scopes = setOf("user")
            redirectUris = setOf("https://localhost:8080/callback")
            authorizedGrantTypes = setOf(
                    AuthorizedGrantType.AUTHORIZATION_CODE
            )
        }

Token store

The InMemoryTokenStore stores all kinds of tokens.

tokenStore = InMemoryTokenStore()

Converters

Access token converter

By default UUIDAccessTokenConverter is used. With a default time-out of 1 hour. To override the time-out for example to half an hour:

accessTokenConverter = UUIDAccessTokenConverter(1800)

To use JWT include the following dependency:

<dependency>
    <groupId>nl.myndocs</groupId>
    <artifactId>oauth2-server-jwt</artifactId>
    <version>${myndocs.oauth.version}</version>
</dependency>

This uses auth0 jwt. To configure:

accessTokenConverter = JwtAccessTokenConverter(
        algorithm = Algorithm.HMAC256("test123"), // mandatory
        accessTokenExpireInSeconds = 1800, // optional default 3600
        jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default
)

Refresh token converter

By default UUIDRefreshTokenConverter is used. With a default time-out of 1 hour. To override the time-out for example to half an hour:

refreshTokenConverter = UUIDRefreshTokenConverter(1800)

To use JWT include the following dependency:

<dependency>
    <groupId>nl.myndocs</groupId>
    <artifactId>oauth2-server-jwt</artifactId>
    <version>${myndocs.oauth.version}</version>
</dependency>

This uses auth0 jwt. To configure:

refreshTokenConverter = JwtRefreshTokenConverter(
        algorithm = Algorithm.HMAC256("test123"), // mandatory
        refreshTokenExpireInSeconds = 1800, // optional default 86400
        jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default
)

Code token converter

By default UUIDCodeTokenConverter is used. With a default time-out of 5 minutes. To override the time-out for example 2 minutes:

codeTokenConverter = UUIDCodeTokenConverter(120)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].