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 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了