NAME

Munge -- MUNGE Uid 'N' Gid Emporium Authentication Service

SYNOPSIS

use Munge;

my $m = Munge.new;

# Strings:
my $encoded = $m.encode('this');
say $m.decode($encoded);

# Blobs:
my $encoded = $m.encode(Buf.new(1,2,3,4));
say $m.decode-buf($encoded);

DESCRIPTION

From the main Munge site: https://github.com/dun/munge/wiki

MUNGE (MUNGE Uid 'N' Gid Emporium) is an authentication service for creating and validating credentials. It is designed to be highly scalable for use in an HPC cluster environment. It allows a process to authenticate the UID and GID of another local or remote process within a group of hosts having common users and groups. These hosts form a security realm that is defined by a shared cryptographic key. Clients within this security realm can create and validate credentials without the use of root privileges, reserved ports, or platform-specific methods.

Context

A new Munge::Context is created for each new Munge object, and many methods are forwarded to that context to query or manipulate it (.error, .cipher, .MAC, .zip, .ttl, .addr4, socket, encode-time, decode-time, uid-restriction, gid-restriction.

Since the context is set during the decoding process, it is likely not what you want for encoding, so you probably want to use separate Munge objects for encoding/decoding.

Encoding/decoding are also not thread-safe, so you should either lock the Munge object during use, or better yet, just make a new (or clone) object for separate threads.

METHODS

new(:cipher, :MAC, :zip, :ttl, :socket, :uid-restriction, :gid-restriction)

Create a new Munge object and context.

The optional arguments are used to initialize the Munge::Context.

clone()

Copy an existing Munge object and context.

encode(Blob $buf?)

encode(Str $str)

Create a credential contained in a base64 string. An optional payload (either Str or Blob) can be encapsulated as well.

decode-buf(Str $cred)

Validates the specified credential, optionally returning the encapsulated payload as a Blob.

Throws an exception for any error, including invalid credentials.

decode(Str $cred)

Validates the specified credential, optionally returning the encapsulated payload as a decoded string.

Throws an exception for any error, including invalid credentials.

EXCEPTIONS

Base exception is X::Munge::Error.

$exception.code will return a Munge::Error enumeration value `EMUNGE_*`

+$exception.code will give you the traditional libmunge error code.