fusionauth 通用sso 解决方案学习二 基本试用
前边有简单的关于fusionauth的环境搭建,以下是关于fusionauth使用的说明
环境搭建
参考https://www.cnblogs.com/rongfengliang/p/12777247.html
配置
- 创建app
- 集成url
- 代码配置
参考代码:https://github.com/rongfengliang/fusionauth-node-example, 参考自官方文档,稍有修改
修改首页配置
index.pug
extends layout
block content
h1= title
if user
p Hello #{user.firstName}
else
a(href='http://localhost:9011/oauth2/authorize?client_id=9822f717-6a43-419a-a2f1-764100a3f50f&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth-redirect') Login
p Welcome to #{title}
- 配置用户权限
- 添加路由
/oauth-redirect
代码:
const express = require('express');
const router = express.Router();
const {FusionAuthClient} = require('@fusionauth/node-client');
const client = new FusionAuthClient('9822f717-6a43-419a-a2f1-764100a3f50f', 'http://localhost:9011');
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', {user: req.session.user, title: 'FusionAuth Example'});
});
/* OAuth return from FusionAuth */
router.get('/oauth-redirect', function (req, res, next) {
// This code stores the user in a server-side session
client.exchangeOAuthCodeForAccessToken(req.query.code,
'9822f717-6a43-419a-a2f1-764100a3f50f',
'Hx7mEG8oXJ-NwjiAqMNBpXUKy-Xtf_t8hbNub9DGHGw',
'http://localhost:3000/oauth-redirect')
.then((response) => {
return client.retrieveUserUsingJWT(response.successResponse.access_token);
})
.then((response) => {
req.session.user = response.successResponse.user;
})
.then(() => {
res.redirect(302, '/');
});
});
module.exports = router;
- 效果
登录
效果
cache
说明
以上是一个简单的集成试用,fusionauth 同时也支持比较强大的主题管理,这点也是比较灵活的,可以自定义配置不同应用的界面(当然也是挺费事的)
参考截图
参考修改登录界面
参考资料
https://fusionauth.io/docs/v1/tech/5-minute-setup-guide
https://github.com/rongfengliang/fusionauth-node-example
https://github.com/FusionAuth/fusionauth-localization
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-04-26 Flagr 配置说明
2019-04-26 Flagr 架构
2019-04-26 flagr 数据库配置
2019-04-26 uclibc,eglibc,glibc,Musl-libc之间的区别和联系
2019-04-26 flagr a/b 测试特性开关&&微服务动态配置工具
2019-04-26 stolon cloud native postgresql 高可用方案
2017-04-26 mysql 用户管理