All Projects → usthe → Sureness

usthe / Sureness

Licence: apache-2.0
A simple and efficient open-source security framework that focus on protection of restful api.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sureness

Cerberus
A demonstration of a completely stateless and RESTful token-based authorization system using JSON Web Tokens (JWT) and Spring Security.
Stars: ✭ 482 (+89.76%)
Mutual labels:  restful-api, spring, authentication, jwt, authorization, spring-security
Spring Boot Webflux Jjwt
Example Spring Boot and WebFlux (Reactive Web) with Spring Security and JWT for token Authentication and Authorization
Stars: ✭ 71 (-72.05%)
Mutual labels:  spring, authentication, jwt, authorization, spring-security
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+725.59%)
Mutual labels:  authentication, jwt, authorization, spring-security, shiro
Buji Pac4j
pac4j security library for Shiro: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 444 (+74.8%)
Mutual labels:  authentication, jwt, authorization, shiro
Spring Boot In Action
Spring Boot 系列实战合集
Stars: ✭ 4,153 (+1535.04%)
Mutual labels:  spring, springboot, jwt, spring-security
Rude Java
Java Practice Projects. 以Java语言为主的各种项目实践,涵盖各个业务、各个功能,并附上高质量文章讲解,其中一些甚至可以单开一个仓库。让你再也不用寻找各种框架demo、项目脚手架。
Stars: ✭ 583 (+129.53%)
Mutual labels:  spring, springboot, jwt, spring-security
Spring Security Pac4j
pac4j security library for Spring Security: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 231 (-9.06%)
Mutual labels:  authentication, jwt, authorization, spring-security
Spring Security React Ant Design Polls App
Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
Stars: ✭ 1,336 (+425.98%)
Mutual labels:  authentication, jwt, authorization, spring-security
Securing Rest Api Spring Security
Spring Boot 2.2.x + Spring 5.2.x Rest Api Security Example
Stars: ✭ 117 (-53.94%)
Mutual labels:  spring, springboot, jwt, spring-security
Cloudopt Next
A simple and modern Java and Kotlin vert.x web framework
Stars: ✭ 211 (-16.93%)
Mutual labels:  restful-api, framework, springboot
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (-39.37%)
Mutual labels:  authentication, jwt, authorization
Spring Reddit Clone
Reddit clone built using Spring Boot, Spring Security with JPA Authentication, Spring Data JPA with MySQL, Spring MVC. The frontend is built using Angular - You can find the frontend source code here - https://github.com/SaiUpadhyayula/angular-reddit-clone
Stars: ✭ 210 (-17.32%)
Mutual labels:  spring, jwt, spring-security
Express Mongodb Rest Api Boilerplate
A boilerplate for Node.js apps / Rest API / Authentication from scratch - express, mongodb (mongoose).
Stars: ✭ 153 (-39.76%)
Mutual labels:  authentication, jwt, authorization
Skill6 Website Backend
java进阶开发,高级版web项目。基于dubbo实现分布式微服务架构,基于spring boot、spring mvc、mybatis、docker、ELK、redis、vue.js、node.js等技术实现的技术分享交流网站。网站名称:技术流,英文名:skill6。主要功能有:登录注册、单点登录、restful设计、文章及评论、代码及资源下载、主题讨论等。持续更新中...
Stars: ✭ 140 (-44.88%)
Mutual labels:  spring, springboot, shiro
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (-35.04%)
Mutual labels:  authentication, jwt, authorization
Pdf Books
📚 PDF 书籍库
Stars: ✭ 134 (-47.24%)
Mutual labels:  spring, springboot, shiro
Ruoyi Oracle
(RuoYi)官方仓库 基于SpringBoot的权限管理系统 易读易懂、界面简洁美观。 核心技术采用Spring、MyBatis、Shiro没有任何其它重度依赖。直接运行即可用
Stars: ✭ 134 (-47.24%)
Mutual labels:  spring, springboot, shiro
Liugh Parent
SpringBoot+SpringCloud Oauth2+JWT+MybatisPlus实现Restful快速开发后端脚手架
Stars: ✭ 2,112 (+731.5%)
Mutual labels:  springboot, jwt, shiro
Registration Login Spring Hsql
Registration and Login Example with Spring Security, Spring Boot, Spring Data JPA, HSQL, JSP
Stars: ✭ 208 (-18.11%)
Mutual labels:  authentication, authorization, spring-security
Stormpath Sdk Java
Official Java SDK for the Stormpath User Management REST API
Stars: ✭ 221 (-12.99%)
Mutual labels:  spring, authentication, authorization

sureness

sureness | 中文文档

A simple and efficient open-source jvm security framework that focus on the protection of restful api.

License Maven GitHub pull request check contexts Gitter GitHub Release Date

sureness - Jvm security framework that focus on protection of rest api | Product Hunt

Home Page: usthe.com/sureness or su.usthe.com

📫 Background

In the mainstream web architecture, how to protect the restful api provided by the back-end through effective and fast authentication has become particularly important.
For existing frameworks, whether it is apache shiro which does not natively support rest, or deeply bound spring, the slower performance and steep learning curve of spring security are not our ideal framework.
Ever since sureness was born, we hope to solve these, provide a restful api, no framework dependency, can dynamically modify permissions, multiple authentication policies, faster, easy to use and extend security framework.

🎡 Introduction

Sureness is a new, permission project which we learn from apache shiro and add some ideas to create it.
Authentication for restful api, based on RBAC, mainly focused on the protection of restful api.
No specific framework dependency(support springboot, quarkus, javalin, ktor and more).
Support dynamic modification of permissions.
Support websocket, mainstream http container(servlet and jax-rs).
Supports JWT, Basic Auth, Digest Auth... Can extend custom supported authentication methods.
High performance due dictionary matching tree.
Good extension interface, demo and document.

The low configuration of sureness, easy to expand, and not coupled with other frameworks, enables developers to quickly and safely protect their projects in multiple scenarios.

🔍 Compare
~ sureness shiro spring security
multi framework support support support need modify not support
restful api support support need modify support
websocket support not support not support
path match dictionary matching tree ant match ant match
annotation support support support support
servlet support support support
jax-rs support not support not support
dynamic modification of permissions support support need modify support need modify
performance fast slower slower
learning curve simple simple steep
📈 Benchmark

benchmark

Benchmark test shows sureness to lose 0.026ms performance compared to frameless application, shiro lose 0.088ms, spring security lose 0.116ms.
In contrast, sureness basically does not consume performance, and the performance (TPS loss) is 3 times that of shiro and 4 times that of spring security.
The performance gap will be further widened as the api matching chain increases.

Detail see Benchmark Test

✌ Framework Sample Support

🔨 Quick Start

🐕 Some Conventions

  • Based RBAC, only has role-resource, no permission action.
  • We treat restful requests as a resource, resource format like requestUri===httpMethod.
    That is the request uri + request method(post,get,put,delete...) is considered as a resource as a whole.
    eg: /api/v2/book===get
  • User belongs some Role -- Role owns Resource -- User can access the resource.

Resource path matching see: URI Match

🐖 Add Sureness In Your Project

When use maven or gradle build project, add coordinate

<dependency>
    <groupId>com.usthe.sureness</groupId>
    <artifactId>sureness-core</artifactId>
    <version>1.0.0</version>
</dependency>
compile group: 'com.usthe.sureness', name: 'sureness-core', version: '1.0.0'

🐵 Use the Default Configuration to Configure Sureness

The default configuration -DefaultSurenessConfig uses the document datasource sureness.yml as the auth datasource.
It supports jwt, basic auth, digest auth authentication.

@Bean
public DefaultSurenessConfig surenessConfig() {
    return new DefaultSurenessConfig();
}

🐮 Load Auth Config DataSource

Sureness authentication requires us to provide our own account data, role permission data, etc. These data may come from text, relational databases, non-relational databases, annotations, etc.
We provide interfaces SurenessAccountProvider, PathTreeProvider for user implement to load data from the dataSource where they want.

  • SurenessAccountProvider - Account datasource provider interface.
  • PathTreeProvider - Resource uri-role datasource provider interface.

Default Document DataSource Config - sureness.yml, see: Default Document DataSource
Annotation DataSource Config Detail - AnnotationLoader, see: Annotation DataSource

If the configuration resource data comes from text, please refer to Sureness integration springboot sample(configuration file scheme)
If the configuration resource data comes from dataBase, please refer to Sureness integration springboot sample(database scheme)

🐐 Add an Interceptor Intercepting All Requests

The essence of sureness is to intercept all rest requests for authenticating and Authorizing.
The interceptor can be a filter or a spring interceptor, it intercepts all request to check them.

SubjectSum subject = SurenessSecurityManager.getInstance().checkIn(servletRequest)

🐰 Implement Auth Exception Handling Process

Sureness uses exception handling process:

  • If auth success, method - checkIn will return a SubjectSum object containing user information.
  • If auth failure, method - checkIn will throw different types of auth exceptions.

Users need to continue the subsequent process based on these exceptions.(eg: return the request response)

Here we need to customize the exceptions thrown by checkIn, passed directly when auth success, catch exception when auth failure and do something:

try {
    SubjectSum subject = SurenessSecurityManager.getInstance().checkIn(servletRequest);
} catch (ProcessorNotFoundException | UnknownAccountException | UnsupportedSubjectException e4) {
    // Create subject error related execption 
} catch (DisabledAccountException | ExcessiveAttemptsException e2 ) {
    // Account disable related exception
} catch (IncorrectCredentialsException | ExpiredCredentialsException e3) {
    // Authentication failure related exception
} catch (UnauthorizedException e5) {
    // Authorization failure related exception
} catch (SurenessAuthenticationException | SurenessAuthorizationException e) {
    // other sureness exception
}

Detail sureness auth exception see: Default Sureness Auth Exception

Have Fun

🥐 Advanced Use

Sureness supports custom subject, custom subjectCreator, custom processor and more.

Before advanced custom extension, let's first understand the general process of sureness:

flow

As in the above process, Subject is created by SubjectCreate according to the request body, and different authentication processors process the supported Subjects.

Sureness provides the following common interfaces as extension points:

  • Subject: Authenticated authorized user's account interface, provide the account's username,password, request resources, roles, etc.
  • SubjectCreate: Create subject interface, provider create method.
  • Processor: Process subject interface, where happen authentication and authorization.
  • PathTreeProvider: Resource data provider, it can load data from txt or database,etc.
  • SurenessAccountProvider: Account data provider, it can load data from txt or database,etc.

Refer to Extension Point for the extended documentation.

  1. 🥊 Custom Subject

Implment Subject, add custom subject content
Implment SubjectCreate to create custom subject
Implment Processor to support custom subject

See Custom Subject

  1. 🔫 Custom SubjectCreator

Implment SubjectCreate to create your custom subject

See Custom SubjectCreator

  1. 🪓 Custom Processor

A subject also can support by different processor, so we can custom processor to support custom subject Implment Processor, set which subject can support and implment processing details

See Custom Processor

  1. 🏹 Custom Datasource

Implment PathTreeProvider, load in DefaultPathRoleMatcher
Implment SurenessAccountProvide, load in processor

See Custom Datasource

Detail please refer to Sureness integration springboot sample(database scheme)

🙋 Contributing

Very welcome to Contribute this project, go further and better with sureness. If you have any questions or suggestions about the project code, please contact @tomsun28 directly.

Components of Repository:

💪 Why Is High Performance

pathRoleMatcher

🛡️ License

Apache License, Version 2.0

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