Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SASL Authentication Mechanism #4

Closed
3 tasks done
bigbes opened this issue Sep 25, 2015 · 0 comments
Closed
3 tasks done

SASL Authentication Mechanism #4

bigbes opened this issue Sep 25, 2015 · 0 comments
Assignees
Labels
feature A new functionality
Milestone

Comments

@bigbes
Copy link
Contributor

bigbes commented Sep 25, 2015

Overview

Most deployments of memcached today exist within trusted networks where clients may freely connect to any server and the servers don't discriminate against them. There are cases, however, where memcached is deployed in untrusted networks or where administrators would like to exercise a bit more control over the clients that are connecting. This page mostly exists to describe the protocol.

Authentication Concepts

Authentication is abstracted from the server using the Simple Authentication and Security Layer. Among other things, this provides administrators with consistent credential management that is mostly independent from the services that are authenticating clients.

Protocol Definitions

Error Codes and Conditions

There are two status codes provided by the SASL protocol to enable authentication:

Unauthorized

If a message is returned with a status code of 0x20, this is considered an authentication or authorization failure. This may be in response to an explicit authentication command indicating the credentials were not accepted or the authorization was otherwise not granted to access the server.

Continue Authentication

Some SASL mechanisms require multiple messages to be sent between the client and server. If a server responds to an authentication message with a status code of 0x21, this will indicate your client needs to do more work to complete the authentication negotiation.

Authentication Not Supported

If a server responds to an authentication request indicating the command is unknown (status 0x81), it likely doesn't support authentication. It is generally acceptable for the client to consider authentication successful when communicating to a server that doesn't support authentication.

Authentication Requests

List Mechanisms

In order to negotiate authentication, a client may need to ask the server what authentication mechanisms it supports. A command 0x20 with no extras, key, or value will request a mechanism list from the server. The mechanisms are returned as a space-separated value.

Authentication Request

To begin an authentication request, send a request with command 0x21, the requested mechanism as the key, and the initial authentication data as the value if any is required for the chosen mechanism.

Authentication Continuation

If the authentication request responded with a continuation request (status 0x21), the body will contain the data needed for computing the next value in the authentication negotiation. The next step's data will be transmitted similarly to the initial step, but using command 0x22. Note that this includes the mechanism within the key as in the initial request.

Error Reference

+-------------+------------------------------------------+
| Status Code | Meaning                                  |
+-------------+------------------------------------------+
| 0x20        | Authentication required / Not Successful |
| 0x21        | Further authentication steps required.   |
+-------------+------------------------------------------+

Command Reference

+----------------------+------+-----------+-----------+
| Command              | Opc  | Key       | Value     |
+----------------------+------+-----------+-----------+
| List Mechanisms      | 0x20 | None      | None      |
| Start Authentication | 0x21 | Mechanism | Auth Data |
| Authentication Step  | 0x22 | Mechanism | Auth Data |
+----------------------+------+-----------+-----------+

SASL Howto

Introduction

In order to use memcached in a hostile network (e.g. a cloudy ISP where the infrastructure is shared and you can't control it), you're going to want some kind of way to keep people from messing with your cache servers.

SASL (as described in RFC2222) is a standard for adding authentication mechanisms to protocols in a way that is protocol independent.

Getting Started

In order to deploy memcached with SASL, you'll need two things:

  1. A memcached server with SASL support (version 1.4.3 or greater built with --enable-sasl)
  2. A client that supports SASL

Configuring SASL

For the most part, you just do the normal SASL admin stuff.

# Create a user for memcached.
saslpasswd2 -a memcached -c cacheuser

Running Memcached

In order to enable SASL support in the server you must use the -S flag.

The -S flag does a few things things:

  1. Enable all of the SASL commands.
  2. Require binary protocol only.
  3. Require authentication to have been successful before commands may be issued on a connection.

P.S.

Original: https://code.google.com/p/memcached/wiki/SASLAuthProtocol
Original: https://code.google.com/p/memcached/wiki/SASLHowto
Motive to duplicate - google source code (with project wikis) is closing.

Plan

  • SASL_LIST_MECHS
  • SASL_AUTH
  • SASL_STEP
@bigbes bigbes added the feature A new functionality label Sep 28, 2015
@bigbes bigbes added this to the 0.0.2 milestone Sep 28, 2015
@bigbes bigbes self-assigned this Sep 28, 2015
bigbes added a commit that referenced this issue Aug 25, 2016
closes gh-4

+ cmd_set isn't invoked in text protocol

closes gh-24
bigbes added a commit that referenced this issue Aug 25, 2016
closes gh-4

+ cmd_set isn't invoked in text protocol

closes gh-24
bigbes added a commit that referenced this issue Aug 25, 2016
closes gh-4

+ cmd_set isn't invoked in text protocol

closes gh-24
@bigbes bigbes closed this as completed in c49af59 Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

No branches or pull requests

1 participant