小工具--Dashy基于Kecloak认证

1.简介

Dashy 是一款既美观又实用的书签管理工具

2.环境准备

    Linux CentOS 7.6 docker

3.部署docker

[root@learn-1 ~]# yum install docker -y
[root@learn-1 ~]# systemctl start docker && systemctl enable docker

4.编辑配置文件

在本地编辑配置文件,用于挂载至容器中

[root@learn-1 ~]# mkdir -p /data/dashy
[root@learn-1 ~]# vim /data/dashy/my-conf.yml

---
# Page meta info, like heading, footer text and nav links
pageInfo:
  title: Dashy
  description: Welcome to your new dashboard!
  navLinks:
  - title: GitHub
    path: https://github.com/Lissy93/dashy
  - title: Documentation
    path: https://dashy.to/docs

# Optional app settings and configuration
appConfig:
  # 设置默认主题 
  theme: colorful
  # 开启网站健康检查
  statusCheck: true
# Main content - An array of sections, each containing an array of items
sections:
- name: Getting Started
  icon: fas fa-rocket
  items:
  - title: Dashy Live
    description: Development a project management links for Dashy
    icon: https://i.ibb.co/qWWpD0v/astro-dab-128.png
    url: https://live.dashy.to/
    target: newtab
  - title: GitHub
    description: Source Code, Issues and Pull Requests
    url: https://github.com/lissy93/dashy
    icon: favicon
  - title: Docs
    description: Configuring & Usage Documentation
    provider: Dashy.to
    icon: far fa-book
    url: https://dashy.to/docs
  - title: Showcase
    description: See how others are using Dashy
    url: https://github.com/Lissy93/dashy/blob/master/docs/showcase.md
    icon: far fa-grin-hearts
  - title: Config Guide
    description: See full list of configuration options
    url: https://github.com/Lissy93/dashy/blob/master/docs/configuring.md
    icon: fas fa-wrench
  - title: Support
    description: Get help with Dashy, raise a bug, or get in contact
    url: https://github.com/Lissy93/dashy/blob/master/.github/SUPPORT.md
    icon: far fa-hands-helping
- name: test1
  #statusCheck: true
  icon: fas fa-rocket
  items:
  - title: baidu
    url: http://www.baidu.com
    target: newtab
    icon: fa fa-sign-in
- name: test2
  #statusCheck: true
  icon: fas fa-rocket
  items:
  - title: google
    url: https://www.google.com
    target: newtab
    icon: fa fa-sign-in

5.启动Dashy容器

docker run -d -p 7777:80 -v /data/dashy/my-conf.yml:/app/public/conf.yml --name my-dashboard --restart=always lissy93/dashy:latest

6.启动Kecloak

docker run -d -p 7778:8080 --name auth-server -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2
Web访问:http://192.168.0.136:7778,用户名/密码:admin/admin

7.对接Dashy

7.1 设置Kecloak

Keycloak 使用领域(类似于租户)来创建隔离的用户组。必须先创建一个领域,然后才能添加第一个用户 登陆控制台:http://192.168.0.136:7778,用户名/密码:admin/admin
创建一个realm,名称自定义,如:demo
创建用户
首次登陆强制修改密码
为用户设置密码
创建client
Client ID 自定义,如:demo Client Protocol 选择:openid-connect Root URL : http://192.168.0.136:7777 —dashy dashboard url
只保留以下配置,其余url删除: Valid Redirect URIs 重定向url,即认证过后跳转的url Web Origins 跳转地址

7.2 在 Dashy 配置文件中启用 Kecloak

vim /data/dashy/my-conf.yml
···
appConfig:
    auth:
        enableKeycloak: true
        keycloak:
            serverUrl: http://192.168.0.136:7778
            realm: Demo
            clientId: demo
            # Keycloak V 17 或更早版本需要配置legacySupport: true
            legacySupport: true
...
# 重启dashy
docker restart my-dashboard

7.3 登录验证

登陆dashy dashboard http://192.168.0.136:7777
首次登陆强制修改密码
经验分享 程序员 微信小程序 职场和发展