n26keychain

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 1 Imported by: 0

README

Keychain Storage for N26 API Client

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

n26keychain uses system keyring as a storage for persisting/getting credentials and token. It supports OS X, Linux (dbus) and Windows.

Prerequisites

  • Go >= 1.17

Install

go get github.com/nhatthm/n26keychain

Usage

n26api.CredentialsProvider

Examples

Build n26api.Client:

package mypackage

import (
	"github.com/google/uuid"
	"github.com/nhatthm/n26api"
	"github.com/nhatthm/n26keychain/credentials"
)

func buildClient() (*n26api.Client, error) {
	deviceID := uuid.New()

	c := n26api.NewClient(
		n26api.WithDeviceID(deviceID),
		credentials.WithCredentialsProvider(),
	)

	return c, nil
}

Persist credentials in system keyring:

package mypackage

import (
	"github.com/google/uuid"
	"github.com/nhatthm/n26keychain/credentials"
)

func persist(deviceID uuid.UUID, username, password string) error {
	c := credentials.New(deviceID)
	
	return c.Update(username, password)
}
auth.TokenStorage
package mypackage

import (
	"github.com/nhatthm/n26api"
	"github.com/nhatthm/n26keychain/token"
)

func buildClient() *n26api.Client {
	return n26api.NewClient(
		token.WithTokenStorage(),
	)
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this

Documentation

Overview

Package n26keychain provides keychain as a storage for credentials and token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage added in v0.2.0

type Storage interface {
	// Set sets password in keychain for user.
	Set(user, password string) error
	// Get gets password from keychain.
	Get(user string) (string, error)
	// Delete deletes secret from keychain.
	Delete(user string) error
}

Storage is a keychain storage.

func NewStorage added in v0.2.0

func NewStorage(service string) Storage

NewStorage creates a keychain storage.

Directories

Path Synopsis
Package credentials provides a token provider.
Package credentials provides a token provider.
mock
Package mock provides mocks for keychain credentials provider.
Package mock provides mocks for keychain credentials provider.
Package mock provide functionalities for mocking keychain storage.
Package mock provide functionalities for mocking keychain storage.
Package test provide functionalities for testing keychain storage.
Package test provide functionalities for testing keychain storage.
Package token provides keychain storage for token.
Package token provides keychain storage for token.
mock
Package mock provides mocks for keychain token storage.
Package mock provides mocks for keychain token storage.

Jump to

Keyboard shortcuts

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