Documentation ¶
Index ¶
- Constants
- type AuthMethod
- type AuthState
- type Client
- func (c *Client) CreateOrganization(ctx context.Context, org models.Organization) (*models.Organization, error)
- func (c *Client) CreateOrganizationCollection(ctx context.Context, orgID string, collection models.Collection) (*models.Collection, error)
- func (c *Client) DeleteOrganization(ctx context.Context, ID string) error
- func (c *Client) DeleteOrganizationCollection(ctx context.Context, orgID, colID string) error
- func (c *Client) DeleteOrganizationUser(ctx context.Context, userID, orgID string) error
- func (c *Client) DeleteUser(ctx context.Context, ID string) error
- func (c *Client) GetOrganization(ctx context.Context, ID string) (*models.Organization, error)
- func (c *Client) GetOrganizationCollection(ctx context.Context, orgID string, collectionID string) (*models.Collection, error)
- func (c *Client) GetOrganizationUser(ctx context.Context, userID, orgID string) (*models.OrganizationUserDetails, error)
- func (c *Client) GetOrganizationUserByEmail(ctx context.Context, email, orgID string) (*models.OrganizationUserDetails, error)
- func (c *Client) GetOrganizationUsers(ctx context.Context, orgID string) (*models.OrganizationUsers, error)
- func (c *Client) GetProfile(ctx context.Context) (*models.User, error)
- func (c *Client) GetUser(ctx context.Context, ID string) (*models.User, error)
- func (c *Client) GetUserByEmail(ctx context.Context, email string) (*models.User, error)
- func (c *Client) InviteOrganizationUser(ctx context.Context, req InviteOrganizationUserRequest, email, orgID string) error
- func (c *Client) InviteUser(ctx context.Context, user models.User) (*models.User, error)
- func (c *Client) LoginWithUserCredentials(ctx context.Context, hashedPassword string) (*TokenResponse, error)
- func (c *Client) PreLogin(ctx context.Context) (*PreloginResponse, error)
- func (c *Client) RegisterUser(ctx context.Context, req RegisterUserRequest) error
- func (c *Client) UpdateOrganization(ctx context.Context, ID string, org models.Organization) (*models.Organization, error)
- func (c *Client) UpdateOrganizationCollection(ctx context.Context, orgID, colID string, collection models.Collection) (*models.Collection, error)
- func (c *Client) UpdateOrganizationUser(ctx context.Context, userID, orgID string, user models.OrganizationUserDetails) (*models.OrganizationUserDetails, error)
- type ClientOption
- func WithAdminToken(token string) ClientOption
- func WithDeviceName(deviceName string) ClientOption
- func WithDeviceType(deviceType string) ClientOption
- func WithHTTPClient(httpClient *http.Client) ClientOption
- func WithOAuth2Credentials(clientID, clientSecret string) ClientOption
- func WithUserCredentials(email, masterPassword string) ClientOption
- type DeleteOrganizationRequest
- type DeviceInfo
- type InviteOrganizationUserRequest
- type OrganizationSecret
- type PreloginResponse
- type RegisterUserRequest
- type TokenResponse
Constants ¶
const ( DefaultDeviceType = "21" DefaultDeviceName = "Vaultwarden_Terraform_Provider" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthMethod ¶ added in v0.2.0
type AuthMethod int
AuthMethod represents the type of authentication being used
const ( AuthMethodNone AuthMethod = iota AuthMethodAdmin AuthMethodUserPassword AuthMethodOAuth2 )
type AuthState ¶ added in v0.3.0
type AuthState struct { // Admin authentication AdminCookie *http.Cookie // User authentication AccessToken string // JWT token TokenExpiresAt time.Time // JWT expiration time PrivateKey *rsa.PrivateKey KdfConfig *models.KdfConfiguration // Organizations data Organizations map[string]OrganizationSecret }
AuthState holds the current authentication state
type Client ¶
type Client struct { // Auth credentials Credentials *models.Credentials // Authenticated state AuthState *AuthState // Device info DeviceInfo *DeviceInfo // contains filtered or unexported fields }
Client represents a Vaultwarden API client
func New ¶
func New(endpoint string, opts ...ClientOption) (*Client, error)
New creates a new Vaultwarden client with the given endpoint and options
func (*Client) CreateOrganization ¶ added in v0.2.0
func (c *Client) CreateOrganization(ctx context.Context, org models.Organization) (*models.Organization, error)
CreateOrganization creates a new Vaultwarden organization
func (*Client) CreateOrganizationCollection ¶ added in v0.3.0
func (c *Client) CreateOrganizationCollection(ctx context.Context, orgID string, collection models.Collection) (*models.Collection, error)
CreateOrganizationCollection creates a new Vaultwarden organization collection
func (*Client) DeleteOrganization ¶ added in v0.2.0
DeleteOrganization deletes an organization by its ID
func (*Client) DeleteOrganizationCollection ¶ added in v0.3.0
func (*Client) DeleteOrganizationUser ¶ added in v0.4.0
DeleteOrganizationUser deletes a user in an organization by their ID
func (*Client) DeleteUser ¶
DeleteUser deletes a user by their ID
func (*Client) GetOrganization ¶ added in v0.2.0
GetOrganization retrieves an organization by its ID
func (*Client) GetOrganizationCollection ¶ added in v0.3.0
func (c *Client) GetOrganizationCollection(ctx context.Context, orgID string, collectionID string) (*models.Collection, error)
GetOrganizationCollection retrieves a specific collection from an organization
func (*Client) GetOrganizationUser ¶ added in v0.4.0
func (c *Client) GetOrganizationUser(ctx context.Context, userID, orgID string) (*models.OrganizationUserDetails, error)
GetOrganizationUser retrieves a user in an organization by their ID
func (*Client) GetOrganizationUserByEmail ¶ added in v0.4.0
func (c *Client) GetOrganizationUserByEmail(ctx context.Context, email, orgID string) (*models.OrganizationUserDetails, error)
GetOrganizationUserByEmail retrieves a user in an organization by their email
func (*Client) GetOrganizationUsers ¶ added in v0.4.0
func (c *Client) GetOrganizationUsers(ctx context.Context, orgID string) (*models.OrganizationUsers, error)
GetOrganizationUsers retrieves all users in an organization
func (*Client) GetProfile ¶ added in v0.3.0
GetProfile retrieves the user's profile
func (*Client) GetUserByEmail ¶ added in v0.4.0
GetUserByEmail retrieves a user by their email address
func (*Client) InviteOrganizationUser ¶ added in v0.4.0
func (c *Client) InviteOrganizationUser(ctx context.Context, req InviteOrganizationUserRequest, email, orgID string) error
InviteOrganizationUser invites a new user to an organization
func (*Client) InviteUser ¶
InviteUser invites a new user to Vaultwarden
func (*Client) LoginWithUserCredentials ¶ added in v0.3.0
func (*Client) PreLogin ¶ added in v0.3.0
func (c *Client) PreLogin(ctx context.Context) (*PreloginResponse, error)
PreLogin retrieves KDF configuration for the given email
func (*Client) RegisterUser ¶ added in v0.2.0
func (c *Client) RegisterUser(ctx context.Context, req RegisterUserRequest) error
RegisterUser registers a new user
func (*Client) UpdateOrganization ¶ added in v0.2.0
func (c *Client) UpdateOrganization(ctx context.Context, ID string, org models.Organization) (*models.Organization, error)
UpdateOrganization updates an organization by its ID
func (*Client) UpdateOrganizationCollection ¶ added in v0.3.0
func (c *Client) UpdateOrganizationCollection(ctx context.Context, orgID, colID string, collection models.Collection) (*models.Collection, error)
UpdateOrganizationCollection updates an existing Vaultwarden organization collection
func (*Client) UpdateOrganizationUser ¶ added in v0.4.3
func (c *Client) UpdateOrganizationUser(ctx context.Context, userID, orgID string, user models.OrganizationUserDetails) (*models.OrganizationUserDetails, error)
UpdateOrganizationUser updates a user in an organization by their ID
type ClientOption ¶ added in v0.3.0
ClientOption defines a function type for configuring the Client
func WithAdminToken ¶
func WithAdminToken(token string) ClientOption
WithAdminToken sets the admin token for the client
func WithDeviceName ¶ added in v0.3.0
func WithDeviceName(deviceName string) ClientOption
WithDeviceName sets a custom device name
func WithDeviceType ¶ added in v0.3.0
func WithDeviceType(deviceType string) ClientOption
WithDeviceType sets a custom device type
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient allows setting a custom HTTP client
func WithOAuth2Credentials ¶ added in v0.3.0
func WithOAuth2Credentials(clientID, clientSecret string) ClientOption
WithOAuth2Credentials sets the client ID and secret for OAuth2 authentication
func WithUserCredentials ¶ added in v0.3.0
func WithUserCredentials(email, masterPassword string) ClientOption
WithUserCredentials sets the email and master password for the client
type DeleteOrganizationRequest ¶ added in v0.2.0
type DeleteOrganizationRequest struct {
MasterPasswordHash string `json:"masterPasswordHash"`
}
DeleteOrganizationRequest represents the request body for deleting an organization
type DeviceInfo ¶ added in v0.3.0
DeviceInfo holds information about the client device
type InviteOrganizationUserRequest ¶ added in v0.4.0
type InviteOrganizationUserRequest struct { Emails []string `json:"emails"` Collections []string `json:"collections"` AccessAll bool `json:"accessAll"` AccessSecretsManager bool `json:"accessSecretsManager"` Type models.UserOrgType `json:"type"` Groups []string `json:"groups"` }
InviteOrganizationUserRequest represents the request body for inviting a user to an organization
type OrganizationSecret ¶ added in v0.3.0
type OrganizationSecret struct { Key symmetrickey.Key OrganizationUUID string Name string }
type PreloginResponse ¶ added in v0.2.0
type PreloginResponse struct { Kdf models.KdfType `json:"kdf"` KdfIterations int `json:"kdfIterations"` KdfMemory int `json:"kdfMemory"` KdfParallelism int `json:"kdfParallelism"` }
PreloginResponse represents the response from the prelogin endpoint
type RegisterUserRequest ¶ added in v0.2.0
type RegisterUserRequest struct { Email string `json:"email"` MasterPasswordHash string `json:"masterPasswordHash"` Name string `json:"name"` Key string `json:"key"` Kdf models.KdfType `json:"kdf"` KdfIterations int `json:"kdfIterations"` KdfMemory int `json:"kdfMemory"` KdfParallelism int `json:"kdfParallelism"` Keys models.KeyPair `json:"keys"` }
RegisterUserRequest represents the request body for registering a user
type TokenResponse ¶ added in v0.2.0
type TokenResponse struct { Kdf models.KdfType `json:"Kdf"` KdfIterations int `json:"KdfIterations"` KdfMemory int `json:"kdfMemory"` KdfParallelism int `json:"kdfParallelism"` Key string `json:"Key"` PrivateKey string `json:"PrivateKey"` ResetMasterPassword bool `json:"ResetMasterPassword"` AccessToken string `json:"access_token"` ExpireIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` Scope string `json:"scope"` TokenType string `json:"token_type"` UnofficialServer bool `json:"unofficialServer"` }
TokenResponse represents the response from the login endpoint