{"id":15041007,"url":"https://github.com/myndocs/kotlin-oauth2-server","last_synced_at":"2025-04-09T18:24:19.058Z","repository":{"id":33431614,"uuid":"144497950","full_name":"myndocs/kotlin-oauth2-server","owner":"myndocs","description":"Flexible OAuth2 server library. Support for multiple frameworks","archived":false,"fork":false,"pushed_at":"2023-03-09T19:36:45.000Z","size":350,"stargazers_count":152,"open_issues_count":8,"forks_count":25,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-02T12:28:08.649Z","etag":null,"topics":["hexagon","http4k","javalin","kotlin","ktor","oauth2","oauth2-server","sparkjava"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myndocs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-12T20:17:47.000Z","updated_at":"2025-01-26T16:37:31.000Z","dependencies_parsed_at":"2024-09-25T01:32:21.653Z","dependency_job_id":"8a553679-8c3b-47ff-9cdc-ea1d882ebbf8","html_url":"https://github.com/myndocs/kotlin-oauth2-server","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myndocs%2Fkotlin-oauth2-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myndocs%2Fkotlin-oauth2-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myndocs%2Fkotlin-oauth2-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myndocs%2Fkotlin-oauth2-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myndocs","download_url":"https://codeload.github.com/myndocs/kotlin-oauth2-server/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248086249,"owners_count":21045307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hexagon","http4k","javalin","kotlin","ktor","oauth2","oauth2-server","sparkjava"],"created_at":"2024-09-24T20:45:23.866Z","updated_at":"2025-04-09T18:24:19.036Z","avatar_url":"https://github.com/myndocs.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin OAuth2 server \n## Goal\nThe goal of this project is to provide a simple OAuth2 library which can be implemented in any framework\n\nConfiguring the oauth2 server for any framework should be simple and understandable.\nIt encourages to adapt to existing implementations instead the other way around.\n\n# Frameworks\n## Setup\n\n### Maven\n\n```xml\n\u003cproperties\u003e\n    \u003cmyndocs.oauth.version\u003e0.7.1\u003c/myndocs.oauth.version\u003e\n\u003c/properties\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n        \u003cartifactId\u003eoauth2-server-core\u003c/artifactId\u003e\n        \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    \n    \u003c!-- In memory dependencies --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n        \u003cartifactId\u003eoauth2-server-client-inmemory\u003c/artifactId\u003e\n        \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n        \u003cartifactId\u003eoauth2-server-identity-inmemory\u003c/artifactId\u003e\n        \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n        \u003cartifactId\u003eoauth2-server-token-store-inmemory\u003c/artifactId\u003e\n        \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Gradle\n```groovy\ndependencies {\n    implementation \"nl.myndocs:oauth2-server-core:$myndocs_oauth_version\"\n    // In memory dependencies\n    implementation \"nl.myndocs:oauth2-server-client-inmemory:$myndocs_oauth_version\"\n    implementation \"nl.myndocs:oauth2-server-identity-inmemory:$myndocs_oauth_version\"\n    implementation \"nl.myndocs:oauth2-server-token-store-inmemory:$myndocs_oauth_version\"\n}\n```\n\n\n### Framework implementation\nThe following frameworks are supported:\n- [Ktor](docs/ktor.md)\n- [Javalin](docs/javalin.md)\n- [http4k](docs/http4k.md)\n- [Sparkjava](docs/sparkjava.md)\n\n## Configuration\n### Routing\nDefault endpoints are configured:\n\n| Type | Relative url |\n| ----- | ------------- |\n| token | /oauth/token |\n| authorize | /oauth/authorize |\n| token info | /oauth/tokeninfo |\n\nThese values can be overridden:\n```kotlin\ntokenEndpoint = \"/custom/token\"\nauthorizationEndpoint = \"/custom/authorize\"\ntokenInfoEndpoint = \"/custom/tokeninfo\"\n```\n\n### In memory \nIn memory implementations are provided to easily setup the project.\n\n#### Identity\nOn the `InMemoryIdentity` identities can be registered. These are normally your users:\n```kotlin\nidentityService = InMemoryIdentity()\n    .identity {\n        username = \"foo-1\"\n        password = \"bar\"\n    }\n    .identity {\n        username = \"foo-2\"\n        password = \"bar\"\n    }\n```\n\n#### Client\nOn the `InMemoryClient` clients can be registered:\n```kotlin\nclientService = InMemoryClient()\n    .client {\n        clientId = \"app1-client\"\n        clientSecret = \"testpass\"\n        scopes = setOf(\"admin\")\n        redirectUris = setOf(\"https://localhost:8080/callback\")\n        authorizedGrantTypes = setOf(\n                AuthorizedGrantType.AUTHORIZATION_CODE,\n                AuthorizedGrantType.PASSWORD,\n                AuthorizedGrantType.IMPLICIT,\n                AuthorizedGrantType.REFRESH_TOKEN\n        )\n    }\n    .client {\n            clientId = \"app2-client\"\n            clientSecret = \"testpass\"\n            scopes = setOf(\"user\")\n            redirectUris = setOf(\"https://localhost:8080/callback\")\n            authorizedGrantTypes = setOf(\n                    AuthorizedGrantType.AUTHORIZATION_CODE\n            )\n        }\n```\n\n#### Token store\nThe `InMemoryTokenStore` stores all kinds of tokens.\n```kotlin\ntokenStore = InMemoryTokenStore()\n```\n\n### Converters\n\n#### Access token converter\nBy default `UUIDAccessTokenConverter` is used. With a default time-out of 1 hour. To override the time-out for example to half an hour:\n```kotlin\naccessTokenConverter = UUIDAccessTokenConverter(1800)\n```\n\nTo use JWT include the following dependency:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n    \u003cartifactId\u003eoauth2-server-jwt\u003c/artifactId\u003e\n    \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\nThis uses [auth0 jwt](https://github.com/auth0/java-jwt). To configure:\n```kotlin\naccessTokenConverter = JwtAccessTokenConverter(\n        algorithm = Algorithm.HMAC256(\"test123\"), // mandatory\n        accessTokenExpireInSeconds = 1800, // optional default 3600\n        jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default\n)\n```\n\n#### Refresh token converter\nBy default `UUIDRefreshTokenConverter` is used. With a default time-out of 1 hour. To override the time-out for example to half an hour:\n```kotlin\nrefreshTokenConverter = UUIDRefreshTokenConverter(1800)\n```\n\nTo use JWT include the following dependency:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enl.myndocs\u003c/groupId\u003e\n    \u003cartifactId\u003eoauth2-server-jwt\u003c/artifactId\u003e\n    \u003cversion\u003e${myndocs.oauth.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\nThis uses [auth0 jwt](https://github.com/auth0/java-jwt). To configure:\n```kotlin\nrefreshTokenConverter = JwtRefreshTokenConverter(\n        algorithm = Algorithm.HMAC256(\"test123\"), // mandatory\n        refreshTokenExpireInSeconds = 1800, // optional default 86400\n        jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default\n)\n```\n#### Code token converter\nBy default `UUIDCodeTokenConverter` is used. With a default time-out of 5 minutes. To override the time-out for example 2 minutes:\n```kotlin\ncodeTokenConverter = UUIDCodeTokenConverter(120)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyndocs%2Fkotlin-oauth2-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyndocs%2Fkotlin-oauth2-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyndocs%2Fkotlin-oauth2-server/lists"}