oauth

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 37 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oauth implements opsgate's built-in OAuth authorization server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePasskeyInvite

func CreatePasskeyInvite(cfg config.BuiltinAuth, issuer, subject string, ttl time.Duration) (string, error)

CreatePasskeyInvite writes a one-time registration invite for subject and returns its URL. subject must be a configured user and the upstream provider must be "passkey".

Types

type Server

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

Server is the authorization server. It is safe for concurrent use.

func New

func New(cfg config.BuiltinAuth, issuer, resource string) (*Server, error)

New returns a Server whose issuer is issuer (an https origin) and whose tokens are only valid for resource (the MCP endpoint URL).

func (*Server) Access

func (s *Server) Access(subject string) (scopes, tools []string, ok bool)

Access returns what a configured user may do when acting from a browser.

func (*Server) Close

func (s *Server) Close() error

Close stops background sweeping and flushes state to disk.

func (*Server) RequireUser

func (s *Server) RequireUser(next func(http.ResponseWriter, *http.Request, string)) http.Handler

RequireUser runs next with an allowed upstream subject, starting a browser login when no live session is present. Login returns only to local paths.

func (*Server) Routes

func (s *Server) Routes(mux *http.ServeMux)

Routes registers OAuth discovery, /oauth/* and the /admin/clients page.

func (*Server) Verify

func (s *Server) Verify(ctx context.Context, token string, r *http.Request) (*auth.TokenInfo, error)

Verify implements auth.TokenVerifier for access tokens issued by s.

func (*Server) VerifyWithTools

func (s *Server) VerifyWithTools(ctx context.Context, token string, r *http.Request) (*auth.TokenInfo, error)

VerifyWithTools verifies an access token and attaches the user's tool policy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL