Skip to content

Commit dbed51d

Browse files
authored
Support Scala 2.12 (#115)
* #109 separate projects * #109 support Scala 2.12
1 parent 27f4aeb commit dbed51d

38 files changed

+14
-692
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: scala
22
scala:
3-
- 2.11.7
3+
- 2.12.1
4+
- 2.11.8
45
jdk:
56
- oraclejdk8
67
notifications:

README.md

Lines changed: 4 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,18 @@ and an access token type called [Bearer](http://tools.ietf.org/html/rfc6750).
1919

2020
## Setup
2121

22-
If you'd like to use this with Play Framework, add "play2-oauth2-provider" to library dependencies of your project.
23-
2422
### Play Framework
2523

26-
```scala
27-
libraryDependencies ++= Seq(
28-
"com.nulab-inc" %% "play2-oauth2-provider" % "1.2.0"
29-
)
30-
```
31-
32-
Library version | Play version
33-
--------------- | ------------
34-
1.2.0 | 2.5.x
35-
0.16.1 | 2.4.x
36-
0.14.0 | 2.3.x
37-
0.7.4 | 2.2.x
24+
See [the project](https://github.com/nulab/play2-oauth2-provider)
3825

3926
### Akka HTTP
4027

41-
```scala
42-
libraryDependencies ++= Seq(
43-
"com.nulab-inc" %% "akka-http-oauth2-provider" % "1.2.0"
44-
)
45-
```
46-
47-
Library version | Akka HTTP version
48-
--------------- | ------------
49-
1.2.0 | 2.4.x
28+
See [the project](https://github.com/nulab/akka-http-oauth2-provider)
5029

5130
### Other frameworks
5231

53-
Add `scala-oauth2-core` instead. In this case, you need to implement your own OAuth provider working with web framework you use.
32+
Add `scala-oauth2-core` library dependencies of your project.
33+
In this case, you need to implement your own OAuth provider working with web framework you use.
5434

5535
```scala
5636
libraryDependencies ++= Seq(
@@ -120,116 +100,3 @@ case class AuthInfo[User](
120100
- inform the client of the scope of the access token issued
121101
- redirectUri
122102
- This value must be enabled on authorization code grant
123-
124-
### Work with Play Framework
125-
126-
You should follow four steps below to work with Play Framework.
127-
128-
* Customizing Grant Handlers
129-
* Define a controller to issue access token
130-
* Assign a route to the controller
131-
* Access to an authorized resource
132-
133-
You want to use which grant types are supported or to use a customized handler for a grant type, you should override the ```handlers``` map in a customized ```TokenEndpoint``` trait.
134-
135-
```scala
136-
class MyTokenEndpoint extends TokenEndpoint {
137-
override val handlers = Map(
138-
OAuthGrantType.AUTHORIZATION_CODE -> new AuthorizationCode(),
139-
OAuthGrantType.REFRESH_TOKEN -> new RefreshToken(),
140-
OAuthGrantType.CLIENT_CREDENTIALS -> new ClientCredentials(),
141-
OAuthGrantType.PASSWORD -> new Password(),
142-
OAuthGrantType.IMPLICIT -> new Implicit()
143-
)
144-
}
145-
```
146-
147-
Here's an example of a customized ```TokenEndpoint``` that 1) only supports the ```password``` grant type, and 2) customizes the ```password``` grant type handler to not require client credentials:
148-
149-
```scala
150-
class MyTokenEndpoint extends TokenEndpoint {
151-
val passwordNoCred = new Password() {
152-
override def clientCredentialRequired = false
153-
}
154-
155-
override val handlers = Map(
156-
OAuthGrantType.PASSWORD -> passwordNoCred
157-
)
158-
}
159-
```
160-
161-
Define your own controller with mixining ```OAuth2Provider``` trait provided by this library to issue access token with customized `TokenEndpoint`.
162-
163-
```scala
164-
import scalaoauth2.provider._
165-
object OAuth2Controller extends Controller with OAuth2Provider {
166-
override val tokenEndpoint = new MyTokenEndpoint()
167-
168-
def accessToken = Action.async { implicit request =>
169-
issueAccessToken(new MyDataHandler())
170-
}
171-
}
172-
```
173-
174-
Then, assign a route to the controller that OAuth clients will access to.
175-
176-
```
177-
POST /oauth2/access_token controllers.OAuth2Controller.accessToken
178-
```
179-
180-
Finally, you can access to an authorized resource like this:
181-
182-
```scala
183-
import scalaoauth2.provider._
184-
object MyController extends Controller with OAuth2Provider {
185-
def list = Action.async { implicit request =>
186-
authorize(new MyDataHandler()) { authInfo =>
187-
val user = authInfo.user // User is defined on your system
188-
// access resource for the user
189-
}
190-
}
191-
}
192-
```
193-
194-
If you'd like to change the OAuth workflow, modify handleRequest methods of `TokenEndPoint` and `ProtectedResource` traits.
195-
196-
### Using Action composition
197-
198-
You can write more easily authorize action by using Action composition.
199-
200-
Play Framework's documentation is [here](https://www.playframework.com/documentation/2.5.x/ScalaActionsComposition).
201-
202-
```scala
203-
object MyController extends Controller {
204-
205-
import scalaoauth2.provider.OAuth2ProviderActionBuilders._
206-
207-
def list = AuthorizedAction(new MyDataHandler()) { request =>
208-
val user = request.authInfo.user // User is defined on your system
209-
// access resource for the user
210-
}
211-
}
212-
```
213-
214-
## Examples
215-
216-
### Play Framework 2.5
217-
218-
- https://github.com/lglossman/scala-oauth2-deadbolt-redis
219-
- https://github.com/tsuyoshizawa/scala-oauth2-provider-example-skinny-orm
220-
221-
### Play Framework 2.3
222-
223-
- https://github.com/davidseth/scala-oauth2-provider-slick
224-
225-
### Play Framework 2.2
226-
227-
- https://github.com/oyediyildiz/scala-oauth2-provider-example
228-
- https://github.com/tuxdna/play-oauth2-server
229-
230-
## Application using this library
231-
232-
- [Typetalk](https://typetalk.in/)
233-
- [Backlog](https://backlogtool.com/)
234-
- [Flic by Shortcut Labs](
235-
)

akka-http-oauth2-provider/src/main/scala/scalaoauth2/provider/OAuth2Provider.scala

Lines changed: 0 additions & 55 deletions
This file was deleted.

akka-http-oauth2-provider/src/test/scala/scalaoauth2/provider/OAuth2ProviderSpec.scala

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)