All Projects → gigsterous → auth-server

gigsterous / auth-server

Licence: Apache-2.0 license
Spring-Boot Auth server

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to auth-server

Login Cidadao
Projeto Login Cidadão
Stars: ✭ 61 (+64.86%)
Mutual labels:  oauth2-server
Symfony4 Ddd
Bootstrap Application for Symfony 4 with Domain Driven Design
Stars: ✭ 126 (+240.54%)
Mutual labels:  oauth2-server
Typescript Mern Starter
Build a real fullstack app (backend+website+mobile) in 100% Typescript
Stars: ✭ 154 (+316.22%)
Mutual labels:  oauth2-server
Cierge
🗝️ Passwordless OIDC authentication done right
Stars: ✭ 1,245 (+3264.86%)
Mutual labels:  oauth2-server
Node Oauth2 Server Example
Working oauth2 server with minimal configuration
Stars: ✭ 115 (+210.81%)
Mutual labels:  oauth2-server
Go Oauth2 Server
A standalone, specification-compliant, OAuth2 server written in Golang.
Stars: ✭ 1,843 (+4881.08%)
Mutual labels:  oauth2-server
Oauth2 Mock Server
A development and test oriented OAuth2 mock server
Stars: ✭ 54 (+45.95%)
Mutual labels:  oauth2-server
Express Gateway
A microservices API Gateway built on top of Express.js
Stars: ✭ 2,583 (+6881.08%)
Mutual labels:  oauth2-server
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+32018.92%)
Mutual labels:  oauth2-server
Springcloud Oauth2
本项目基于spring-cloud-starter-oauth2搭建的认证中心和资源服务器的微服务项目,项目不仅仅简单的demo,项目的出发点在于实战应用。本项目为笔者花了不少时间和精力整理出来的,只需要稍微调整就可应用于实际项目当中,并且项目包含大量注释,不仅可以让你会用,也可让你了解到一些流程、一些原理上的东西。认证中心完成密码模式、授权码模式、刷新token模式、简化模式、以及自定义的手机号验证码模式。
Stars: ✭ 154 (+316.22%)
Mutual labels:  oauth2-server
Flask Oauthlib
YOU SHOULD USE https://github.com/lepture/authlib
Stars: ✭ 1,429 (+3762.16%)
Mutual labels:  oauth2-server
Rageframe2
一个基于Yii2高级框架的快速开发应用引擎
Stars: ✭ 1,553 (+4097.3%)
Mutual labels:  oauth2-server
Doorkeeper Provider App
An example OAuth 2 provider application using the Doorkeeper gem, Rails and Devise
Stars: ✭ 146 (+294.59%)
Mutual labels:  oauth2-server
Node Oauth2 Server Mongo Example
Working oauth2 server with mongodb storage and minimal configuration
Stars: ✭ 76 (+105.41%)
Mutual labels:  oauth2-server
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+370.27%)
Mutual labels:  oauth2-server
Yii2 Oauth2
OAuth2 wrapper for Yii2 applications
Stars: ✭ 58 (+56.76%)
Mutual labels:  oauth2-server
Ex oauth2 provider
Making OAuth 2 provider and authentication with http bearer as simple as possible for Elixir and Phoenix apps
Stars: ✭ 137 (+270.27%)
Mutual labels:  oauth2-server
Light Oauth2
A fast, light and cloud native OAuth 2.0 authorization microservices based on light-4j
Stars: ✭ 247 (+567.57%)
Mutual labels:  oauth2-server
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+7613.51%)
Mutual labels:  oauth2-server
Oauth2
OAuth 2.0 server library for the Go programming language.
Stars: ✭ 2,173 (+5772.97%)
Mutual labels:  oauth2-server

Authentication Service

This is an example authorization server written in Spring Boot 2. It is not meant to be used in production as it is but could be easily modified into a fully functional solution.

This auth server could be extended to provide other resources and act as an resource server or it can be used with an existing resource server and only provide authentication/authorization by managing user OAuth2 tokens.

If you like this application and have questions or feature requests, feel free to open an issue/PR.

🌟 Features

  1. Username and password Authentication
  2. OAuth2 Access + Refresh Token Provision
  3. Registration with e-mail confirmation
  4. Basic account management including password change, forgotten password, e-mail change and account deletion
  5. Multilingual support
  6. Logout including token invalidation
  7. Easy SonarQube, Jacoco and Checkstyle intagration for code-quality monitoring
  8. Basic unit and integration test coverage with example tests

🔧 Installation

This is a Gradle project and uses lombok, which needs to be configured in any IDE.

Furthermore, in order to use the e-mail features of this application, the smtp configuration needs to be injected either via application.properties or environmental variables. The following variables are required:

  • spring.mail.host
  • spring.mail.username
  • spring.mail.password

🚦 Usage

The application can be run using the included Gradle wrapper: ./gradlew bootRun

Similarly, building the application can be run using ./gradlew clean build. This step includes also checkstyle step which reports all code quality violations and prints them into console and report files. Checkstyle rules can be edited in the configuration file checkstyle/checkstyle.xml.

If you wish to use SonarQube for code quality checks and unit test coverage, run ./gradlew sonarqube -Dsonar.host.url=<sonar-url> -Dsonar.login=<sonar-password>

Spring REST docs are also implemented and basic documentation can be generated using ./gradlew asciidoc.

In case you have an existing resource server written in Spring Boot and wish to connect it to this authorization server, make sure you have the required Spring Boot security & OAuth2 dependencies and include the following line in your resource server's application.properties:

security.oauth2.resource.userInfoUri=http://localhost:9000/auth/user

🤝 Authentication

To authenticate, call:

curl --user 'gigy:secret' \
-d 'grant_type=password&[email protected]&password=password' \
-X POST http://localhost:9000/auth/oauth/token

A sample response will look like this:

{  
   "access_token":"d6ce77cb-28e0-44d1-8d59-ce214822ef4b",
   "token_type":"bearer",
   "refresh_token":"98eb7a5f-5aee-4a96-b173-239401ea78d4",
   "expires_in":3599,
   "scope":"read write"
}

♻️ Refresh Token

Access Token has a limited validity. Once expired, the Refresh Token can be used in order to obtain a new one without using user's credentials.

To refresh the Access Token, simply call:

curl -i --user 'gigy:secret' \
-d "grant_type=refresh_token&client_id=gigy&client_secret=secret&refresh_token=98eb7a5f-5aee-4a96-b173-239401ea78d4" \
-X POST http://localhost:9000/auth/oauth/token

Which will return a new Access Token:

{  
   "access_token":"b14d9a0c-450d-4fd9-bd46-d5a70422e4c7",
   "token_type":"bearer",
   "refresh_token":"98eb7a5f-5aee-4a96-b173-239401ea78d4",
   "expires_in":3599,
   "scope":"read write"
}

Notice that the Refresh Token remains the same even after receiving a new Access Token.

👤 User Data

To verify that the Access Token works well, we can call the /user endpoint method:

curl -i -H "Accept: application/json" \
-H "Authorization: Bearer b14d9a0c-450d-4fd9-bd46-d5a70422e4c7" \
-X GET http://localhost:9000/auth/user

Which returns:

{  
   "id":1,
   "username":"[email protected]",
   "password":"$2a$10$D4OLKI6yy68crm.3imC9X.P2xqKHs5TloWUcr6z5XdOqnTrAK84ri",
   "enabled":true,
   "authorities":[],
   "accountNonExpired":true,
   "accountNonLocked":true,
   "credentialsNonExpired":true
}

This method is exposed to all secured services within the whole system. The way it works and returns data is according to Spring Boot standards.

⚠️ Error Handling

📛 Expired Access Token

When Access Token expires, server will return an error, such as:

{  
   "error":"invalid_token",
   "error_description":"Invalid access token: b14d9a0c-450d-4fd9-bd46-d5a70422e4c7"
}

This error signals that token is invalid. We can assume that the token has expired and can attempt to get a new one using the Refresh Token.

⛔️ Invalid Refresh Token

There are numerous reasons for Refresh Token to be invalidated. When that happens, server will return:

{  
   "error":"invalid_grant",
   "error_description":"Invalid refresh token: 98eb7a5f-5aee-4a96-b173-239401ea78d5"
}

When this error occurs, user credentials have to be used in order to authenticate the user again.

🔖 License

The code is released under the Apache 2.0 license. See LICENSE for details.

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