ounauth

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

README

ounauth

Go Reference

codeberg.org/cynth/ounauth implements the absolute bare minimum you need to get github.com/coreos/go-oidc/v3 to approve a JWT access token. It is for writing test suites for those of us stuck in the hell universe of systems which use OAuth Client Credentials to make bearer tokens for server-to-server authentication.

It is not secure; it should not be taken as any example of how to design a real OpenID/OAuth server or client; it has no persistence and no configuration available beyond what’s necessary to stub custom claims; it doesn't get happy, it doesn't get sad, it doesn't laugh at your jokes, it just generates tokens.

License

Copyright 2024 Hyacinth Alas

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Documentation

Overview

Package ounauth implements the absolute bare minimum you need to get github.com/coreos/go-oidc/v3 to approve a JWT access token. It is for writing test suites for those of us stuck in the hell universe of systems which use OAuth Client Credentials to make bearer tokens for server-to-server authentication.

It is not secure; it should not be taken as any example of how to design a real OpenID/OAuth server or client; it has no persistence and no configuration available beyond what’s necessary to stub custom claims; it doesn't get happy, it doesn't get sad, it doesn't laugh at your jokes, it just generates tokens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OP

type OP struct {
	// contains filtered or unexported fields
}

OP is definitely not an OpenID Provider.

func New

func New() *OP

New definitely makes an OP though. By default no clients are authorized.

func (*OP) Configuration

func (o *OP) Configuration(w http.ResponseWriter, r *http.Request)

Configuration implements the OpenID Configuration endpoint.

func (*OP) JWKS

func (o *OP) JWKS(w http.ResponseWriter, r *http.Request)

JWKS implements the JWKS retrieval endpoint.

func (*OP) Mux

func (o *OP) Mux() *http.ServeMux

Mux returns a mux with the default routes set up.

func (*OP) Route

func (o *OP) Route(mux *http.ServeMux)

Route adds the default routes to a mux.

func (*OP) StubClient

func (o *OP) StubClient(id, secret string, claims jwt.MapClaims)

StubClient authorizes a client with an ID and secret, and any claims it should get. The only default claims are exp, iss, and aud, which are required to validate a token; any others (even normal ones like scopes) must be specified by calling this.

It is, unfortunately, safe for concurrent use.

func (*OP) TestServer

func (o *OP) TestServer(t interface{ Cleanup(func()) }) *httptest.Server

TestServer returns an server bound to the provided test’s lifetime, implementing OP’s routes.

func (*OP) Token

func (o *OP) Token(w http.ResponseWriter, r *http.Request)

Token implements the token endpoint. All tokens are valid for a year.

Directories

Path Synopsis
cmd
op

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳