drzablspw01655860 2017-02-18 18:37
浏览 57

为简单的golang网络应用添加ldap支持的简单方法是什么?

I have an internal tool written in golang, with a simple web interface which is just a single web page.

Now I need to add a "login with ldap" feature but don't know much about the web stuff, is there something like a "middleware" which I could simply plug into my application without introducing a whole "web framework"?

  • 写回答

1条回答 默认 最新

  • douzhanjia0773 2017-02-18 19:07
    关注

    The first part of this is the UX - if you go with HTTP basic authentication, you can probably avoid writing any code, assuming there's a webserver in front of your app most will have authentication support. If you want to stick to go, http.Request makes handling basic pretty easy, and there are many ways of composing net/http based handlers together, so bikeshed away.

    If you require an integrated login form, then of course you'll have to write that logic, but you can take a micro service style approach, and implement that logic by calling to an HTTP basic auth based service internally. I think this approach makes sense if you prefer to use a generic LDAP authentication (e.g. nginx/apache module or something like that), but not if you want to talk to the LDAP server yourself.

    As for the actual credentials, if you do need to do that manually, there are multiple LDAP implementations in go. I've had success with go-ldap for both binding and legacy password validation by fetching fields as an admin user.

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等