douyuan5600 2015-03-17 09:34
浏览 114
已采纳

GO中的用户身份验证系统

Does a pre-made user authentication system exist in Go?

I am coming from a Ruby background, and I would really like to see something similar to Ruby on Rails' device which is a complete user management system. It takes care of everything from creating forms to hashing and salting passwords. It also takes care of storing data to the database, setting up sessions and more.

I have found that there is package called goth which allows for social logins (facebook, twitter ++) but it does not handle storage of the user credentials. It also does not allow for "normal" signup with email + password.

All I can seem to find on this topic for Go is some tutorials on how to make your own basic, very unsafe, user login system.

I would really love to see a system which takes care of the user auth as well as allows for social login via OAuth/OAuth2. Does anything like this exist?

The solution I am after would most likely be part of, or a plugin for, a Go web framework.

Background

I am considering moving my Rails app over to a higher performance framework because my current rails app is using way to much RAM. Thus my eyes went to Go. However, without a solid user auth system I can't convert to Go. To make your own user auth system is not a very good practice.

  • 写回答

1条回答 默认 最新

  • dtz88967 2015-03-17 10:33
    关注

    Short answer: no.

    Long answer: Ruby on Rails is a framework, Go is a language. Making a "universal" authentication system for Go would be a huge task and/or would have to be very opinionated by design, as most auth systems rely on a session store and/or database. Rails can do this (with libs. like Devise) because parts of the framework like ActiveRecord and ActionController provide an abstract API that Devise can talk to.

    For the most part, you'll need to tie together a few libraries to get what you need w/ Go. "Gluing" things together is a commonly preferred way to do things, and monolithic/kitchen sink frameworks aren't typically favoured.

    Some suggestions for libraries:

    These won't give you distinct user types, write your queries for you, etc. I found writing my own "two user level" (regular vs. admin) auth to be fairly straightforward using server-side sessions, a single User table and a piece of HTTP middleware that wraps "need auth" routes and inspects the session, else it re-directs users to a login page (and saves the current URL for a re-direct after).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记