auth

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides cookie management for authenticated social media scraping.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainSources

func ChainSources(ctx context.Context, platform string, sources ...Source) (map[string]string, error)

ChainSources returns cookies from the first source that provides them.

func EnvVarsForPlatform

func EnvVarsForPlatform(platform string) []string

EnvVarsForPlatform returns the environment variable names for a platform. This is useful for generating help messages.

func NewCookieJar

func NewCookieJar(domain string, cookies map[string]string) (*cookiejar.Jar, error)

NewCookieJar creates an http.CookieJar populated with the given cookies for a domain.

Types

type BrowserSource

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

BrowserSource reads cookies from browser cookie stores.

func NewBrowserSource

func NewBrowserSource(logger *slog.Logger) *BrowserSource

NewBrowserSource creates a new browser cookie source.

func (*BrowserSource) Cookies

func (s *BrowserSource) Cookies(ctx context.Context, platform string) (map[string]string, error)

Cookies returns cookies for the given platform from browser stores.

type EnvSource

type EnvSource struct{}

EnvSource reads cookies from environment variables.

func (EnvSource) Cookies

func (EnvSource) Cookies(_ context.Context, platform string) (map[string]string, error)

Cookies returns cookies for the given platform from environment variables.

type Source

type Source interface {
	// Cookies returns cookies for the given platform, or nil if unavailable.
	Cookies(ctx context.Context, platform string) (map[string]string, error)
}

Source represents a source of authentication cookies.

type StaticSource

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

StaticSource provides cookies from a static map. This is useful for testing or when cookies are provided via options.

func NewStaticSource

func NewStaticSource(cookies map[string]string) *StaticSource

NewStaticSource creates a cookie source from a static map.

func (*StaticSource) Cookies

func (s *StaticSource) Cookies(_ context.Context, _ string) (map[string]string, error)

Cookies returns the static cookies regardless of platform.

Jump to

Keyboard shortcuts

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