• Stars
    star
    534
  • Rank 79,718 (Top 2 %)
  • Language
    Scala
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OAuth 2.0 server-side implementation written in Scala

oauth2-server for Scala CI

The OAuth 2.0 server-side implementation written in Scala.

This provides OAuth 2.0 server-side functionality and supporting function for Play Framework and Akka HTTP.

The idea of this library originally comes from oauth2-server which is Java implementation of OAuth 2.0.

Supported OAuth features

This library supports all grant types.

  • Authorization Code Grant (PKCE Authorization Code Grants are supported)
  • Resource Owner Password Credentials Grant
  • Client Credentials Grant
  • Implicit Grant

and an access token type called Bearer.

Setup

Play Framework

See the project

Akka HTTP

See the project

Other frameworks

Add scala-oauth2-core library dependencies of your project. In this case, you need to implement your own OAuth provider working with web framework you use.

libraryDependencies ++= Seq(
  "com.nulab-inc" %% "scala-oauth2-core" % "1.6.0"
)

How to use

Implement DataHandler

Whether you use Play Framework or not, you have to implement DataHandler trait and make it work with your own User class that may be already defined in your application.

case class User(id: Long, name: String, hashedPassword: String)

class MyDataHandler extends DataHandler[User] {

  def validateClient(maybeClientCredential: Option[ClientCredential], request: AuthorizationRequest): Future[Boolean] = ???

  def findUser(maybeClientCredential: Option[ClientCredential], request: AuthorizationRequest): Future[Option[User]] = ???

  def createAccessToken(authInfo: AuthInfo[User]): Future[AccessToken] = ???

  def getStoredAccessToken(authInfo: AuthInfo[User]): Future[Option[AccessToken]] = ???

  def refreshAccessToken(authInfo: AuthInfo[User], refreshToken: String): Future[AccessToken] = ???

  def findAuthInfoByCode(code: String): Future[Option[AuthInfo[User]]] = ???

  def findAuthInfoByRefreshToken(refreshToken: String): Future[Option[AuthInfo[User]]] = ???

  def deleteAuthCode(code: String): Future[Unit] = ???

  def findAccessToken(token: String): Future[Option[AccessToken]] = ???

  def findAuthInfoByAccessToken(accessToken: AccessToken): Future[Option[AuthInfo[User]]] = ???

}

If your data access is blocking for the data storage, then you just wrap your implementation in the DataHandler trait with Future.successful(...).

For more details, refer to Scaladoc of DataHandler.

AuthInfo

DataHandler returns AuthInfo as authorized information. AuthInfo is made up of the following fields.

case class AuthInfo[User](
  user: User,
  clientId: Option[String],
  scope: Option[String],
  redirectUri: Option[String],
  codeChallenge: Option[String] = None,
  codeChallengeMethod: Option[CodeChallengeMethod] = None
)
  • user
    • user is authorized by DataHandler
  • clientId
    • clientId which is sent from a client has been verified by DataHandler
    • If your application requires client_id for client authentication, you can get clientId as below
      • val clientId = authInfo.clientId.getOrElse(throw new InvalidClient())
  • scope
    • inform the client of the scope of the access token issued
  • redirectUri
    • This value must be enabled on authorization code grant
  • codeChallenge:
    • This value is OPTIONAL. Only set this value if doing a PKCE authorization request. When set, PKCE rules apply on the AuthorizationCode Grant Handler
    • This value is from a PKCE authorization request. This is the challenge supplied during the auth request if given.
  • codeChallengeMethod:
    • This value is OPTIONAL and used only by PKCE when a codeChallenge value is also set.
    • This value is from a PKCE authorization request. This is the method used to transform the code verifier. Must be either Plain or S256. If not specified and codeChallenge is provided then Plain is assumed (per RFC7636)

More Repositories

1

zxcvbn4j

This is a java port of zxcvbn, which is a JavaScript password strength generator.
Java
302
star
2

backlog-bulk-issue-registration-gas

GoogleスプレッドシートによるBacklog課題一括登録
TypeScript
138
star
3

nginx-length-hiding-filter-module

nginx filter module to append random generated string to the end of HTML response
C
61
star
4

backlog4j

Java library for Backlog API version 2
Java
40
star
5

nginx-upstream-jvm-route

Forked version of https://code.google.com/p/nginx-upstream-jvm-route/
C
39
star
6

backlog-js

Backlog API version 2 client for browser and node.
TypeScript
33
star
7

play2-oauth2-provider

This library is enabled using scala-oauth2-provider in Play Framework
Scala
28
star
8

BacklogMigration-Redmine

Migrate your projects from Redmine to Backlog.
Scala
28
star
9

akka-http-oauth2-provider

This library is enabled using scala-oauth2-provider in Akka HTTP
Scala
25
star
10

emoji-data-ts

Utilities for emoji data in TypeScript
TypeScript
22
star
11

go-typetalk

go-typetalk is a GO client library for accessing the Typetalk API.
Go
20
star
12

hubot-typetalk

A hubot adapter for Typetalk.
JavaScript
18
star
13

backlog-power-ups

JavaScript
18
star
14

fabric-sample

fabric sample to define tasks using Task subclass
Ruby
15
star
15

go-git-http-xfer

Implements Git HTTP Transport.
Go
15
star
16

BacklogMigration-Jira

Migrate your projects from JIRA to the Backlog.
Scala
10
star
17

commit-guidelines

8
star
18

go-todo-example

A todo manager written in Go using Test Driven Development technique (TDD)
Go
8
star
19

BacklogMigration-CybozuLive

Migrate your projects from CybozuLive to the Backlog.
Scala
7
star
20

nginx-too-many-requests-retryafter-patch

Dockerfile
6
star
21

NLBURLAction

Objective-C
6
star
22

asclip

ActionScript library for clipboard copy
ActionScript
6
star
23

botbuilder-typetalk

Typetalk bot connector for Microsoft BotBuilder.
TypeScript
6
star
24

thymeleaf-servlet-example

JavaScript
6
star
25

book-template

TeX
5
star
26

drupalcamp-taipei-2014

Sample repository for Drupal Camp 2014 Taipei
PHP
5
star
27

fluent-plugin-typetalk

Fluent plugin to emit notifications to Typetalk
Ruby
4
star
28

backlog-migration-common

Scala
4
star
29

franz-recipe-backlog

Backlog for Franz 5
JavaScript
4
star
30

hydralibs

Collections of frontend libraries
TypeScript
3
star
31

cacoo-diagram-contents-api-sample

Sample to understand how to use the diagram contents API.
Java
2
star
32

cacoo-api-sample

Sample Web Application with Cacoo API
Java
2
star
33

typetalk-google-translate-bot

A Typetalk bot try to translate posted messages in English.
Go
2
star
34

nginx-gzip-filter-allow-weak-etag-patch

Nginx patch to allow gzip filter to keep weak ETag
2
star
35

autog

Graph autolayout library in Go
Go
1
star
36

backlog-importer

Scala
1
star
37

knockout-example-todo

JavaScript
1
star
38

franz-recipe-typetalk

Typetalk for Franz 5
JavaScript
1
star
39

play2-auth-sample

This repository is sample code for authentication
Scala
1
star
40

ansible-sample

Ansible module samples
Shell
1
star
41

typetalk-gcal-bot

JavaScript
1
star
42

backlog4j-httpclient

Java
1
star
43

backlog-chrome-sandbox

backlog chrome extension sandbox
JavaScript
1
star
44

fblike-hashtag

JavaScript
1
star
45

typetalk-webhook-play-example

Example code for webhook in Typetalk http://www.typetalk.in
Scala
1
star
46

echelon-2013-scm-selenium

Echelon Ignite 2013 Thailand Workshop Sample Selenium
Python
1
star
47

echelon-2013-scm-webapp

Echelon Ignite 2013 Thailand Workshop Sample Web Application
JavaScript
1
star
48

timezone-picker

1
star
49

typetalk-orb

Create custom Typetalk notifications for CircleCI job statuses
1
star
50

nu-cookie-banner

nulab cookie banner package
JavaScript
1
star
51

echelon-2013-scm-server

Echelon Ignite 2013 Thailand Workshop Sample Server Configuration
Ruby
1
star