user

package
v0.0.0-...-538f495 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2014 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateKey = errors.New("Duplicate key")
	ErrInvalidKey   = errors.New("Invalid key")
	ErrKeyNotFound  = errors.New("Key not found")
)
View Source
var ErrUserNotFound = errors.New("User not found")

Functions

func AddKey

func AddKey(uName string, k map[string]string) error

Adds a key into a user.

Stores the key in the user's document and write it in authorized_keys.

Returns an error in case the user does not exist.

func Remove

func Remove(name string) error

Removes a user. Also removes it's associated keys from authorized_keys and repositories It handles user with repositories specially when: - a user has at least one repository:

  • if he/she is the only one with access to the repository, the removal will stop and return an error
  • if there are more than one user with access to the repository, gandalf will first revoke user's access and then remove the user permanently

- a user has no repositories: gandalf will simply remove the user

func RemoveKey

func RemoveKey(uName, kName string) error

RemoveKey removes the key from the database and from authorized_keys file.

If the user or the key is not found, returns an error.

Types

type Key

type Key struct {
	Name      string
	Body      string
	Comment   string
	UserName  string
	CreatedAt time.Time
}

func (*Key) String

func (k *Key) String() string

type KeyList

type KeyList []Key

func ListKeys

func ListKeys(uName string) (KeyList, error)

ListKeys lists all user's keys.

If the user is not found, returns an error

func (KeyList) MarshalJSON

func (keys KeyList) MarshalJSON() ([]byte, error)

type User

type User struct {
	Name string `bson:"_id"`
}

func New

func New(name string, keys map[string]string) (*User, error)

Creates a new user and write his/her keys into authorized_keys file.

The authorized_keys file belongs to the user running the process.

Jump to

Keyboard shortcuts

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