<p>Hi <a href="/r/golang" rel="nofollow">r/golang</a>, I am new to Go and currently trying to do implement user authentication for my web.</p>
<p>I came across AuthBoss and I found it to be a comprehensive user auth library which suits my needs well.</p>
<p>However when I read through the codes, the "Storer" made me confused.</p>
<p>I just want make a simple "Register / Login / Logout / Posting" system which works with traditional database, but the doc says </p>
<blockquote>
<p>Authboss makes no presumptions about how you want to store your data.</p>
</blockquote>
<p>and I don't know how to implement it with an SQL database. </p>
<p>Any opensource example for this? Do Gophers usually work with databases or do they have other common approach?</p>
<hr/>**评论:**<br/><br/>aarondl: <pre><p>Hey there. I'm the Author of this library. First off I want to make sure you're using v2 of the library. Check which branch you're using, it should be the v2 branch (the master branch Readme mentions this). Secondly reddit isn't the place for asking questions about a specific library. On our Readme there's a mailing list (Google groups) that you can use or you could open a github issue to talk to us directly about problems.</p>
<p>In v2 the ServerStorer (which replaces the v1 storer) is a lot more obvious how to implement. Both of them however can easily be implemented with an sql database. Try that out and post on github/mailing list if you still run into problems. Thanks for trying out Authboss :) </p></pre>hinsxd: <pre><p>Oh I don't expect authors to appear in my post, what a pleasure!</p>
<p>Well I didn't realize the the difference between the master branch and v2 branch. Does master means v1 currently? I should have just installed authboss using </p>
<pre><code>go get github.com/volatiletech/authboss
</code></pre>
<p>So is that v1? And I should uninstall it and install v2 again?</p>
<p>As for the implementation of the database approach, I think I will repost it in github. Thanks for the guidance ;)</p></pre>aarondl: <pre><p>Yep. That's correct. Currently v2 is in rc stage which is why it's not in the master branch. Which means some things may break yet, but it'll be as small as we can manage, for example the Flash message interface is probably going to change soon to be a separate interface and separate cookie.</p>
<p>However the effort in moving from v1 to v2 is non-trivial so even if you have to change a little bit of stuff you'll save a lot of headache in general. You can also pin to a specific tag to avoid dealing with the breaking changes (current latest rc is v2.0.0-rc4) until you're ready.</p>
<p>So lastly because it's a branch and not in master, generally you can clone like this (keep in mind this assumes your GOPATH is a single directory and not multiple):</p>
<pre><code>mkdir -p $GOPATH/src/github.com/volatiletech
git clone --branch v2 git@github.com:volatiltech/authboss.git $GOPATH/src/github.com/volatiletech/authboss
</code></pre>
<p>One more problem is that godoc.org doesn't support branches, so you can run your own godoc server (it's pre-installed with Go):</p>
<pre><code>godoc -http :8080
</code></pre>
<p>Now you can see the v2 godoc documentation if you browse to http://localhost:8080/pkg/github.com/volatiletech/authboss/</p></pre>SpecialGoat: <pre><p>After a quick search I found <a href="https://gitter.im/go-authboss/authboss/archives/2016/08/09" rel="nofollow">this</a>. Check out the comment there's a link to an example of a mysql storer. I haven't tested it but I'm sure it would put you in the right direction.</p></pre>aarondl: <pre><p>Thanks for helping out SpecialGoat. The <a href="https://github.com/volatiletech/authboss-sample/tree/v2" rel="nofollow">sample</a> is a good place to start for sure. It's v2 branch includes the version that works with v2. Did want to also mention that we've stopped using gitter just so people are aware.</p></pre>SouthAfricanPickle: <pre><p>Sorry if this is not the right context to ask but, since the opportunity is here...</p>
<p>What options are there for password-less login with AuthBoss, if not, are any plans for it in the future?</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传