Introduction and sharing of apollo-portal permissions in apollo configuration center

I. Introduction

This article uses apollo configuration center 1.5.0 to introduce

The configuration center for containerized deployment, unzip it from the officially downloaded apollo-portal.jar package, and find that spring.profiles.active=github,auth

Insert picture description here

The above meaning is to use auth for authentication. Using this authentication means to follow the default user authority relationship of apollo, and to use the session mode that does not separate the front and back ends for authentication.

If you download the apollo configuration center source code from github, the parameter of spring.profiles.active has no default value

spring:
  application:
    name: apollo-portal
  profiles:
    active: ${apollo_profile}

1.1 It can be seen from the excerpt from the official website

Apollo introduction
Insert picture description here

实现方式一:使用Apollo提供的Spring Security简单认证
可能很多公司并没有统一的登录认证系统,如果自己实现一套会比较麻烦。Apollo针对这种情况,从0.9.0开始提供了利用Spring Security实现的Http Basic简单认证版本
...
实现方式二: 接入公司的统一登录认证系统
这种实现方式的前提是公司已经有统一的登录认证系统,最常见的比如SSO、LDAP等。接入时,实现以下SPI。其中UserService和UserInfoHolder是必须要实现的.

From the above statement, the configuration center is still particularly flexible. But sometimes, having permissions is still more troublesome. If we want to cancel permissions, what should we do.

Very simple, just delete auth. For example spring.profiles.active=github

2. Ways to waive authentication

Although it is said that the login interface is less, there is still the concept of an account. The default account of the apollo configuration center is apollo.

Once you log in, you are using the apollo account

2.1 Modify the apollo account, use your own account by default

If you want to modify the apollo account, you use your own account by default, and you can only configure it by modifying the source code.

The location of the source code is com.ctrip.framework.apollo.portal.spi.defaultimpl

Insert picture description here

By modification

  @Override
  public UserInfo getUser() {
    UserInfo userInfo = new UserInfo();
    userInfo.setUserId("已经存在portal中的账号");
    return userInfo;
  }

DefaultUserService.java 也要进行对应的修改

After modification, repackage and deploy, you can use spring.profiles.active=github

2.2 The significance of this modification

Nowadays, many companies are adopting microservices, separating the front and back ends. If you want to customize the front-end interface of apollo, this is the most convenient way.

Step 1
Introduce apollo-portal to the registry dependency and call it through microservices

Step 2
Clear the interface of the apollo-portal interface, write the front-end interface yourself and call it.

Guess you like

Origin blog.csdn.net/qq_34168515/article/details/113386643