All Projects → nulab → Scala Oauth2 Provider

nulab / Scala Oauth2 Provider

Licence: mit
OAuth 2.0 server-side implementation written in Scala

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Scala Oauth2 Provider

heimdall
Painless OAuth 2.0 Server for CodeIgniter 4 🔥
Stars: ✭ 36 (-93.06%)
Mutual labels:  oauth2-server
angular2-social-login
Angular 2 OAuth social login facebook, google, LinkedIn etc using NodeJS server
Stars: ✭ 40 (-92.29%)
Mutual labels:  oauth2-server
Tkey
以材料最全、示例最多为目标的单点登录系统(SSO)
Stars: ✭ 295 (-43.16%)
Mutual labels:  oauth2-server
spring-security-oauth-sample
使用Spring Security OAuth实现OAuth 2.0授权的一个实例
Stars: ✭ 13 (-97.5%)
Mutual labels:  oauth2-server
genkan
🔑 The future of Kitsu's Authentication
Stars: ✭ 13 (-97.5%)
Mutual labels:  oauth2-server
mern-google-login
Authentication flow for React & Express.js application using Google OAuth
Stars: ✭ 39 (-92.49%)
Mutual labels:  oauth2-server
oauth2
Interface oriented implementation, no coupling with the model and database, support for GC
Stars: ✭ 12 (-97.69%)
Mutual labels:  oauth2-server
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (-28.13%)
Mutual labels:  oauth2-server
phoenix oauth2 provider
Get an OAuth 2 provider running in your phoenix with controllers, views and models in just two minutes
Stars: ✭ 72 (-86.13%)
Mutual labels:  oauth2-server
Glewlwyd
Single Sign On server, OAuth2, Openid Connect, multiple factor authentication with, HOTP/TOTP, FIDO2, TLS Certificates, etc. extensible via plugins
Stars: ✭ 292 (-43.74%)
Mutual labels:  oauth2-server
QuickStart-admin-Cloud
基于spring boot 2.0.8 目前集成了spring security oauth2 (server and client)、springboot-admin、openfeign、hystrix,zuul(后续会替换成gateway),config.....等组件
Stars: ✭ 25 (-95.18%)
Mutual labels:  oauth2-server
jpsite-security-oauth2-open
微服务开放API授权平台
Stars: ✭ 21 (-95.95%)
Mutual labels:  oauth2-server
spring-boot-oauth2-server
Sample standalone OAuth2 authorization server using Spring Boot
Stars: ✭ 29 (-94.41%)
Mutual labels:  oauth2-server
oauth2
A standalone OAuth2 & SSO server based on go-oauth2
Stars: ✭ 107 (-79.38%)
Mutual labels:  oauth2-server
Node Oauth2 Server
Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in node.js
Stars: ✭ 3,626 (+598.65%)
Mutual labels:  oauth2-server
kotlin-oauth2-server
Flexible OAuth2 server library. Support for multiple frameworks
Stars: ✭ 123 (-76.3%)
Mutual labels:  oauth2-server
mcloud-oauth2-server
使用Spring OAuth2实现的OAuth2 资源服务器以及认证服务器
Stars: ✭ 57 (-89.02%)
Mutual labels:  oauth2-server
Example Oauth2 Server
Example for OAuth 2 Server for Authlib.
Stars: ✭ 499 (-3.85%)
Mutual labels:  oauth2-server
Oauth2 Server
spring boot (springboot 2+) oauth2 server sso 单点登录 认证中心 JWT,独立部署,用户管理 客户端管理
Stars: ✭ 363 (-30.06%)
Mutual labels:  oauth2-server
Hiauth
HiAuth是一个开源的基于Oauth2协议的认证、授权系统。
Stars: ✭ 273 (-47.4%)
Mutual labels:  oauth2-server

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.5.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)
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].