【问题标题】:Etherpad: Best Way to hook into authEtherpad:连接身份验证的最佳方式
【发布时间】:2013-12-28 19:55:13
【问题描述】:

我正在为 etherpad 制作一个插件,用于检查用户是否经过身份验证。如果不是,则显示只读。我已经走到这一步了:

var eejs = require('ep_etherpad-lite/node/eejs');
var readOnlyManager = require("ep_etherpad-lite/node/db/ReadOnlyManager");

exports.route = function(hook_name, args, cb){
    args.app.get('/p/:pad', function(req, res){
        if(req.params.pad.indexOf('r.') === 0){
            res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req}));
        } else {
            if(req.session.user){
                res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req}));
            } else {
                readOnlyManager.getReadOnlyId(req.params.pad, function(err, readonlyID){
                    res.redirect('/p/'+readonlyID);
                });
            }
        }
    });
}

exports.logout = function(hook_name, args, cb){
    args.app.get('/logout', function(req, res){
      req.session.destroy(function(){
        res.redirect('/');
      });
    });
}

但我不能使用发布路由来让我自己的用户登录。如果我访问 /login 时,我怎样才能获得像一般身份验证这样的请求?

【问题讨论】:

    标签: node.js express etherpad


    【解决方案1】:

    我在 Etherpad 中编写了很多身份验证机制,但那是几年前的事了,我不知道从那以后它发生了多大的变化。

    Etherpad documentation 中提供了您需要的 API 端点和有关身份验证工作原理的文档,特别是身份验证在authentication documentation 中进行了讨论。

    很难从您的问题中看出,但您似乎希望在 /login 处拥有某种登录页面?如果是这样,请查看 Etherpad 如何实现基本身份验证并通过在 /login 处创建新的快速端点来适应它

    有各种插件(包括我开发的)可以用来创建新的 express 端点,an example is available in the ep_email_notifications Etherpad plugin

    我从你的问题中得到了正确的结果吗?

    【讨论】:

    • 部分是的 :) 我已经尝试了 **itload 的东西,但似乎无法让它工作。但是指向授权文档,我必须更仔细地阅读它们。
    猜你喜欢
    • 2021-05-19
    • 2011-01-26
    • 1970-01-01
    • 2015-07-14
    • 2020-10-12
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    相关资源
    最近更新 更多