Skip to content

Token service for authentication, support Redis, database, memory and JWT Token.

License

Notifications You must be signed in to change notification settings

spark2fire/alberti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auth

Token service for authentication, support Redis, database, memory and JWT Token.

Designed for Spring Boot projects.

Maven

<dependency>
    <groupId>cn.spark2fire.alberti</groupId>
    <artifactId>auth-jwt</artifactId>
    <version>0.0.7</version>
</dependency>

Support Types

Redis

Store the token in Redis server.

Database

Store the token in database table.

Memory

Default

JWT

JWT Token store in client.

Endpoints

Login

POST /accounts/login
{
	"username": "user",
	"password": "bf3916a0-a7e0-4177-9b74-fa5b0b7e438f",
	"rememberMe": false
}

Logout

POST /accounts/logout
X-ACCESS-TOKEN: {{TOKEN}}

Get Principal

GET /accounts/principal
X-ACCESS-TOKEN: {{TOKEN}}

Token Usage

Add token in Header or Parameter X-ACCESS-TOKEN.

Configuration

cn:
  spark2fire:
    auth:
      idle-timeout: 30
      header-name: "X-ACCESS-TOKEN"
      table-name: "t_token"
      redis-prefix: "TOKEN:a:"
      jwt:
        secretKey: ""
        issuer: "spark2fire"
        subject: "auth0"
        audience: "web"

Example

package cn.spark2fire.example

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class ExampleApplication

fun main(args: Array<String>) {
    runApplication<ExampleApplication>(*args)
}

About

Token service for authentication, support Redis, database, memory and JWT Token.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages