session

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBearerTokenContext added in v0.0.2

func WithBearerTokenContext(ctx context.Context, bearerToken *BearerToken) context.Context

WithBearerTokenContext returns a new context with the provided BearerToken.

Types

type BasicAuth

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

BasicAuth represents a basic authentication session for the Teamwork API.

func NewBasicAuth

func NewBasicAuth(username, password, server string) *BasicAuth

NewBasicAuth creates a new BasicAuth session with the provided username and password. The server parameter must identify the Teamwork installation, such as "https://yourcompany.teamwork.com".

func (*BasicAuth) Authenticate

func (b *BasicAuth) Authenticate(_ context.Context, req *http.Request) error

Authenticate implements the Session interface for BasicAuth.

func (*BasicAuth) Server

func (b *BasicAuth) Server() string

Server returns the server URL for the BasicAuth session.

type BearerToken

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

BearerToken represents a session for the Teamwork API using Bearer Token authentication. It implements the Session interface, allowing it to be used with the Teamwork Engine for authenticated requests.

func NewBearerToken

func NewBearerToken(token string, server string) *BearerToken

NewBearerToken creates a new BearerToken session with the provided token. The server parameter must identify the Teamwork installation, such as "https://yourcompany.teamwork.com".

func (*BearerToken) Authenticate

func (b *BearerToken) Authenticate(_ context.Context, req *http.Request) error

Authenticate implements the Session interface for BearerToken.

func (*BearerToken) Server

func (b *BearerToken) Server() string

Server returns the server URL for the BearerToken session.

type BearerTokenContext added in v0.0.2

type BearerTokenContext struct{}

BearerTokenContext represents a session that uses a bearer token for authentication extracted from the context. It's possible to inject the token into the context using the WithBearerTokenContext function.

func NewBearerTokenContext added in v0.0.2

func NewBearerTokenContext() *BearerTokenContext

NewBearerTokenContext creates a new BearerTokenContext instance.

func (*BearerTokenContext) Authenticate added in v0.0.2

func (b *BearerTokenContext) Authenticate(ctx context.Context, req *http.Request) error

Authenticate implements the Session interface for BearerTokenContext.

func (*BearerTokenContext) Server added in v0.0.2

func (b *BearerTokenContext) Server() string

Server returns the server URL for the BearerTokenContext session. This is a dummy implementation since it's not accessible at this point.

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

Cookie represents a session for the Teamwork API using cookie-based authentication. It implements the Session interface, allowing it to be used with the Teamwork Engine for authenticated requests.

func NewCookie

func NewCookie(value string, server string) *Cookie

NewCookie creates a new Cookie session with the provided value. The server parameter must identify the Teamwork installation, such as "https://yourcompany.teamwork.com".

func (*Cookie) Authenticate

func (c *Cookie) Authenticate(_ context.Context, req *http.Request) error

Authenticate implements the Session interface for Cookie.

func (*Cookie) Server

func (c *Cookie) Server() string

Server returns the server URL for the Cookie session.

type OAuth2

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

OAuth2 represents a session for the Teamwork API using OAuth2 authentication. It implements the Session interface, allowing it to be used with the Teamwork Engine for authenticated requests.

func NewOAuth2

func NewOAuth2(clientID, clientSecret string, opts ...OAuth2Option) *OAuth2

NewOAuth2 creates a new OAuth2 session with the provided client ID and client secret.

func (*OAuth2) Authenticate

func (o *OAuth2) Authenticate(ctx context.Context, req *http.Request) error

Authenticate implements the Session interface for OAuth2.

func (*OAuth2) Server

func (o *OAuth2) Server() string

Server returns the server URL for the OAuth2 session. If the authentication did not happen yet this may be empty.

type OAuth2Option

type OAuth2Option func(*OAuth2)

OAuth2Option defines a function type that can modify the OAuth2 initial configuration.

func WithOAuth2CallbackServerAddr

func WithOAuth2CallbackServerAddr(host string) OAuth2Option

WithOAuth2CallbackServerAddr sets the OAuth2 callback host. By default, it uses "localhost:0", which means the callback will be handled on a random port on localhost.

func WithOAuth2Client

func WithOAuth2Client(client *http.Client) OAuth2Option

WithOAuth2Client sets the HTTP client for the OAuth2 session. By default, it uses http.DefaultClient.

func WithOAuth2Logger

func WithOAuth2Logger(logger *slog.Logger) OAuth2Option

WithOAuth2Logger sets the logger for the OAuth2 session. If not set, it uses a default logger that writes to the standard output.

func WithOAuth2Server

func WithOAuth2Server(server string) OAuth2Option

WithOAuth2Server sets the OAuth2 authorization server URL. By default, it uses "https://teamwork.com".

Jump to

Keyboard shortcuts

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