Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Go framework or package that provides canned user authentication support?

I've gotten pretty spoiled by the mature frameworks available in Python (Django/Flask), so as I'm starting to learn Go, I have to wonder if there are any similar frameworks already in existence in Go to django.contrib.auth or Flask-Login?

The main use case is to handle simple user authentication and be able to extend it to accommodate some permissions-based routing within the app.

like image 647
Sologoub Avatar asked Mar 12 '13 23:03

Sologoub


People also ask

Does Go have a framework?

The echo framework used in Go is another high-performance, extensible, and minimalist web framework in Golang. It has a highly optimized HTTP router with zero dynamic memory allocation that smartly prioritizes routes. It is used to build robust and scalable REST APIs, which can easily be organized into groups.

How does Auth0 authentication work?

Each time a user needs to prove their identity, your application redirects to your Auth0 tenant and Auth0 will do what's needed to verify the user's identity which often includes redirecting the user to the Universal Login Page to collect their credentials and/or provide them other options for login, such as social or ...

What type of authentication is Auth0?

Auth0 uses the OpenID Connect (OIDC) Protocol and OAuth 2.0 Authorization Framework to authenticate users and get their authorization to access protected resources.


2 Answers

As far as I know, there are not. The closest out-of-the-box authentication you can probably get is via Google AppEngine, where the user's Google account can be retrieved and certain paths can be scoped for app administrators only.

In a standard Go web server, you will generally need to roll your own auth, but it's not as difficult as it sounds. Many frameworks isolate you from decisions which are actually quite important; in typical Go fashion, you'll need to make these decisions based on the needs of your app, and then pick the existing libraries that are right for you.

Login page

Wherever you need your users to log in, you will probably use an HTML form. These will typically be rendered using the html/template package. To retrieve the values when the form is submitted, use request.FormValue.

Database

There are a number of ways to store user information; on the filesystem with os or in a SQL database using database/sql. There are mature drivers for some NoSQL databases as well, including MongoDB and Redis.

Passwords

To compute and compare hashes to passwords, you'll want to use a preexisting mechanism so that you don't have to reinvent it yourself. For this, the go.crypto subrepository provides a bcrypt package.

Sessions

If you want to store session data, you can use a solution like gorilla/sessions. Based on your security needs, you can store the session data directly in a (optionally secured) cookie or you can store it in a backend an only store a session ID in the cookie.

like image 91
Kyle Lemons Avatar answered Nov 16 '22 02:11

Kyle Lemons


From the READ.me

Allows your Martini application to support user login via an OAuth 2.0 backend.

https://github.com/martini-contrib/oauth2

like image 26
Leahcim Avatar answered Nov 16 '22 01:11

Leahcim