Spring Cloud Gateway
Приклад casdoor-springcloud-gateway-example показує, як використовувати casdoor-spring-boot-starter як плагін OAuth2 у Spring Cloud Gateway. Нижче описані кроки його використання.
Крок 1: Розгортання Casdoor
Deploy Casdoor in production mode. See Server installation. Ensure the server is reachable and you can sign in at the login page (e.g. admin / 123).
Крок 2: Ініціалізація Spring Cloud Gateway
Use the example code as-is or adapt it to your application.
Вам потрібен сервіс шлюзу та принаймні один бізнес-сервіс. У цьому прикладі, casdoor-gateway є сервісом шлюзу, а casdoor-api - бізнес-сервісом.
Крок 3: Додавання залежності
Додайте залежність casdoor-spring-boot-starter до вашого проекту Spring Cloud Gateway.
Для Apache Maven:
/casdoor-gateway/pom.xml
<!-- https://mvnrepository.com/artifact/org.casbin/casdoor-spring-boot-starter -->
<dependency>
<groupId>org.casbin</groupId>
<artifactId>casdoor-spring-boot-starter</artifactId>
<version>1.x.y</version>
</dependency>
Для Gradle:
// https://mvnrepository.com/artifact/org.casbin/casdoor-spring-boot-starter
implementation group: 'org.casbin', name: 'casdoor-spring-boot-starter', version: '1.x.y'