@@ -4,9 +4,8 @@ The goal of this project is to provide a simple OAuth2 library which can be impl
44
55Configuring the oauth2 server for any framework should be simple and understandable.
66It encourages to adapt to existing implementations instead the other way around.
7- ## Frameworks
8- ### Ktor
9- Setup
7+ # Maven
8+ Include the following repository in order to download the artifacts
109``` xml
1110<repositories >
1211 <repository >
1514 </repository >
1615</repositories >
1716```
17+
18+ Setting the version in properties
19+ ``` xml
20+ <properties >
21+ <myndocs .oauth.version>0.1.1</myndocs .oauth.version>
22+ </properties >
23+ ```
24+ # Frameworks
25+ ## Ktor
26+ Include the following dependencies
27+
1828``` xml
1929<dependency >
2030 <groupId >nl.myndocs</groupId >
4858</dependency >
4959```
5060
51- Basic setup for Ktor:
61+ In memory example for Ktor:
5262``` kotlin
5363embeddedServer(Netty , 8080 ) {
5464 install(Oauth2ServerFeature ) {
@@ -69,8 +79,62 @@ embeddedServer(Netty, 8080) {
6979}.start(wait = true )
7080```
7181
72- ## Custom implementation
73- ### Identity service
82+ ## Javalin
83+ Include the following dependencies
84+ ``` xml
85+ <dependency >
86+ <groupId >nl.myndocs</groupId >
87+ <artifactId >kotlin-oauth2-server-core</artifactId >
88+ <version >${myndocs.oauth.version}</version >
89+ </dependency >
90+ <dependency >
91+ <groupId >nl.myndocs</groupId >
92+ <artifactId >kotlin-oauth2-server-client-inmemory</artifactId >
93+ <version >${myndocs.oauth.version}</version >
94+ </dependency >
95+ <dependency >
96+ <groupId >nl.myndocs</groupId >
97+ <artifactId >kotlin-oauth2-server-javalin</artifactId >
98+ <version >${myndocs.oauth.version}</version >
99+ </dependency >
100+ <dependency >
101+ <groupId >nl.myndocs</groupId >
102+ <artifactId >kotlin-oauth2-server-identity-inmemory</artifactId >
103+ <version >${myndocs.oauth.version}</version >
104+ </dependency >
105+ <dependency >
106+ <groupId >nl.myndocs</groupId >
107+ <artifactId >kotlin-oauth2-server-token-store-inmemory</artifactId >
108+ <version >${myndocs.oauth.version}</version >
109+ </dependency >
110+ ```
111+
112+ In memory example for Javalin:
113+ ``` kotlin
114+ Javalin .create().apply {
115+ enableOauthServer {
116+ identityService = InMemoryIdentity ()
117+ .identity {
118+ username = " foo"
119+ password = " bar"
120+ }
121+
122+ clientService = InMemoryClient ()
123+ .client {
124+ clientId = " testapp"
125+ clientSecret = " testpass"
126+ scopes = setOf (" ROLE_CLIENT" )
127+ redirectUris = setOf (" https://localhost:7000/callback" )
128+ }
129+
130+ tokenStore = InMemoryTokenStore ()
131+
132+ accessTokenConverter = UUIDAccessTokenConverter (1 )
133+ }
134+ }.start(7000 )
135+ ```
136+ # Custom implementation
137+ ## Identity service
74138Users can be authenticate through the identity service. In OAuth2 terms this would be the resource owner.
75139
76140``` kotlin
@@ -84,7 +148,7 @@ fun validScopes(forClient: Client, identity: Identity, scopes: Set<String>): Boo
84148Each of the methods that needs to be implemented contains ` Client ` . This could give you extra flexibility.
85149For example you could have user base per client, instead of have users over all clients.
86150
87- ### Client service
151+ ## Client service
88152Client service is similar to the identity service.
89153
90154``` kotlin
@@ -93,7 +157,7 @@ fun clientOf(clientId: String): Client?
93157fun validClient (client : Client , clientSecret : String ): Boolean
94158```
95159
96- ### Token store
160+ ## Token store
97161The following methods have to be implemented for a token store.
98162
99163``` kotlin
0 commit comments