Bearer Token Generator (bearertoken/token.go)

omnara · internal/bearertoken/token.go · go · Apache-2.0
ai, auth, security, tag:token, tag:crypto, tag:validation

Generates and validates bearer tokens for authentication and authorization.

// Source: https://github.com/omnara-ai/omnara | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package bearertoken

import (
	"crypto/rand"
	"errors"
	"fmt"
	"hash/crc32"
	"io"
	"strings"
)

type Kind string

const (
	KindPersonalAccess Kind = "pat"
	KindOrganization   Kind = "org"
	KindDaemon         Kind = "daemon"
	KindOAuthAccess    Kind = "oauth"
)

const (
	alphabet       = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
	secretLength   = 43
	checksumLength = 6

	personalAccessPrefix = "omnara_" + string(KindPersonalAccess) + "_v1_"
	organizationPrefix   = "omnara_" + string(KindOrganization) + "_v1_"
	daemonPrefix         = "omnara_" + string(KindDaemon) + 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key