identity

package
v0.0.0-...-afa1830 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingIdentityKeys = errors.New("at least one identity public key is missing")

Functions

func Create

func Create(ctx context.Context, exec boil.ContextExecutor, redConn *redis.Client, identity *Identity) error

Create ...

func CreateAccount

func CreateAccount(ctx context.Context, exec boil.ContextExecutor, account *Account) error

CreateAccount ...

func HasCrypto

func HasCrypto(ctx context.Context, exec boil.ContextExecutor, accountID string) (bool, error)

HasCrypto ...

func NotificationAck

func NotificationAck(ctx context.Context, exec boil.ContextExecutor, identityID string, notifIDs []int) error

NotificationAck acknowledged_at to time.Now() for all unacknowledged notification of the received identity id if notifIds don't belong to the identity id, it will be ignored

func NotificationBulkCreate

func NotificationBulkCreate(ctx context.Context, exec boil.ContextExecutor, redConn *redis.Client, identityIDs []string, nType string, details null.JSON) error

NotificationBulkCreate ...

func NotificationCount

func NotificationCount(ctx context.Context, exec boil.ContextExecutor, filters NotificationFilters) (n int, err error)

NotificationCount unacknowledged notifications for received identity id

func NotificationCreate

func NotificationCreate(ctx context.Context, exec boil.ContextExecutor, redConn *redis.Client, identityID string, nType string, details null.JSON) error

NotificationCreate ...

func NotificationMarkAutoInvitationUsed

func NotificationMarkAutoInvitationUsed(ctx context.Context, exec boil.ContextExecutor, cryptoactionID string) error

NotificationMarkAutoInvitationUsed ...

func ProfileConfigShare

func ProfileConfigShare(
	ctx context.Context, exec boil.ContextExecutor,
	identityID, informationType string,
) error

ProfileConfigShare ...

func ProfileConfigUnshare

func ProfileConfigUnshare(
	ctx context.Context, exec boil.ContextExecutor,
	identityID, informationType string,
) error

ProfileConfigUnshare ...

func SetIdentityPubkey

func SetIdentityPubkey(ctx context.Context, exec boil.ContextExecutor, identityID string, pubkey null.String) error

func Update

func Update(ctx context.Context, exec boil.ContextExecutor, identity *Identity) error

Update ...

func UpdateAccount

func UpdateAccount(ctx context.Context, exec boil.ContextExecutor, account *Account) error

UpdateAccount ...

Types

type Account

type Account struct {
	ID            string
	Password      string
	BackupData    string
	BackupVersion int
}

Account ...

func GetAccount

func GetAccount(ctx context.Context, exec boil.ContextExecutor, accountID string) (ret Account, err error)

GetAccount ...

type AvatarAmazonS3

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

AvatarAmazonS3 ...

func NewAvatarAmazonS3

func NewAvatarAmazonS3(region, bucket string) (*AvatarAmazonS3, error)

NewAvatarAmazonS3 init an S3 session

func (*AvatarAmazonS3) Delete

func (s *AvatarAmazonS3) Delete(ctx context.Context, avatar *AvatarFile) error

Delete ...

func (*AvatarAmazonS3) Upload

func (s *AvatarAmazonS3) Upload(ctx context.Context, avatar *AvatarFile) (string, error)

Upload ...

type AvatarFile

type AvatarFile struct {
	Filename  string
	Extension string

	Data io.Reader
}

AvatarFile ...

type AvatarFileSystem

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

AvatarFileSystem ...

func NewAvatarFileSystem

func NewAvatarFileSystem(avatarLocation, avatarURL string) *AvatarFileSystem

NewAvatarFileSystem constructor /!\ NOT SAFE TO USE IN PRODUCTION

func (*AvatarFileSystem) Delete

func (fs *AvatarFileSystem) Delete(ctx context.Context, avatar *AvatarFile) error

Delete an avatar from the file system

func (*AvatarFileSystem) Upload

func (fs *AvatarFileSystem) Upload(ctx context.Context, avatar *AvatarFile) (string, error)

Upload an avatar in file system directory and return its path

type AvatarRepo

type AvatarRepo interface {
	Upload(context.Context, *AvatarFile) (string, error)
	Delete(context.Context, *AvatarFile) error
}

AvatarRepo ...

type ConfigProfileView

type ConfigProfileView struct {
	Email bool `json:"email"`
}

ConfigProfileView ...

func ProfileConfigGet

func ProfileConfigGet(ctx context.Context, exec boil.ContextExecutor, identityID string) (c ConfigProfileView, err error)

ProfileConfigGet ...

type Filters

type Filters struct {
	IdentifierValue null.String
	IdentifierKind  null.String
	IDs             []string
	AccountID       null.String
}

Filters ...

type IdentifierKind

type IdentifierKind string

IdentifierKind ...

const (
	// EmailIdentifier ...
	AnyIdentifierKind   IdentifierKind = "any"
	IdentifierKindEmail IdentifierKind = "email"
	IdentifierKindOrgID IdentifierKind = "org_id"
)

type Identity

type Identity struct {
	ID              string         `json:"id"`
	AccountID       string         `json:"account_id"`
	IdentifierValue string         `json:"identifier_value"`
	IdentifierKind  IdentifierKind `json:"identifier_kind"`
	DisplayName     string         `json:"display_name"`
	Notifications   string         `json:"notifications"`
	AvatarURL       null.String    `json:"avatar_url"`
	Color           null.String    `json:"color"`
	Level           int            `json:"level"`
	MFAMethod       string         `json:"mfa_method"`
	IdentityPublicKeys
}

Identity ...

func Get

func Get(ctx context.Context, exec boil.ContextExecutor, identityID string) (ret Identity, err error)

Get ...

func GetByIdentifier

func GetByIdentifier(ctx context.Context, exec boil.ContextExecutor, value string, kind IdentifierKind) (ret Identity, err error)

GetByIdentifier using value and kind... received AnyIdentifierKind will set no filter on identifier kind

func List

func List(ctx context.Context, exec boil.ContextExecutor, filters Filters) ([]*Identity, error)

List ...

func Require

func Require(ctx context.Context, exec boil.ContextExecutor, redConn *redis.Client, identifierValue string) (Identity, error)

Require identity, create it if not existing

func (*Identity) GetAvailableAMRs

func (i *Identity) GetAvailableAMRs(ctx context.Context, exec boil.ContextExecutor) (amrs oidc.MethodRefs, err error)

GetAvailableAMRs ...

func (*Identity) GetRequiredACR

func (i *Identity) GetRequiredACR() oidc.ClassRef

GetRequiredACR ...

func (*Identity) SetAllIdentityKeys

func (i *Identity) SetAllIdentityKeys(pubkeys IdentityPublicKeys) error

SetAllIdentityKeys is a shorthand for setting **all 4 identity keys** of the account. For now it will only fail if NaCl keys are missing, since AES-RSA keys are still optional to avoid breaking changes

type IdentityPublicKeys

type IdentityPublicKeys struct {
	Pubkey                    null.String `json:"pubkey"`
	NonIdentifiedPubkey       null.String `json:"non_identified_pubkey"`
	PubkeyAesRsa              null.String `json:"pubkey_aes_rsa,omitempty"`
	NonIdentifiedPubkeyAesRsa null.String `json:"non_identified_pubkey_aes_rsa,omitempty"`
}

type IntraprocessHelper

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

IntraprocessHelper offers a set of functions to interact with the identity package entities without having to pass any storage context executor - in general from external modules wishing to access some data but not owning the storage connection behind it. NOTE: no transaction logic can be then used.

func NewIntraprocessHelper

func NewIntraprocessHelper(ssoDB *sql.DB, redConn *redis.Client) *IntraprocessHelper

NewIntraprocessHelper ...

func (IntraprocessHelper) Get

func (ih IntraprocessHelper) Get(ctx context.Context, identityID string) (Identity, error)

Get ...

func (IntraprocessHelper) GetByIdentifierValue

func (ih IntraprocessHelper) GetByIdentifierValue(ctx context.Context, identifierValue string) (Identity, error)

Get ...

func (IntraprocessHelper) List

func (ih IntraprocessHelper) List(ctx context.Context, filters Filters) ([]*Identity, error)

List ...

func (IntraprocessHelper) NotificationBulkCreate

func (ih IntraprocessHelper) NotificationBulkCreate(ctx context.Context, identityIDs []string, nType string, details null.JSON) error

NotificationBulkCreate ...

type Notification

type Notification struct {
	ID             int       `json:"id"`
	Type           string    `json:"type"`
	Details        null.JSON `json:"details"`
	CreatedAt      time.Time `json:"created_at"`
	AcknowledgedAt null.Time `json:"acknowledged_at"`
	// contains filtered or unexported fields
}

Notification ...

func NotificationList

func NotificationList(
	ctx context.Context, exec boil.ContextExecutor,
	filters NotificationFilters,
) ([]*Notification, error)

NotificationList returns list of notifications linked to the received identity id - handles pagination.

type NotificationFilters

type NotificationFilters struct {
	IdentityID string
	Type       null.String
	Used       null.Bool
	Offset     null.Int
	Limit      null.Int
}

type ProfileView

type ProfileView struct {
	ID                        string      `json:"id"`
	DisplayName               string      `json:"display_name"`
	AvatarURL                 null.String `json:"avatar_url"`
	IdentifierValue           string      `json:"identifier_value"`
	IdentifierKind            string      `json:"identifier_kind"`
	Contactable               bool        `json:"contactable"`
	NonIdentifiedPubkey       null.String `json:"non_identified_pubkey"`
	NonIdentifiedPubkeyAesRsa null.String `json:"non_identified_pubkey_aes_rsa"`
}

ProfileView ...

func ProfileGet

func ProfileGet(ctx context.Context, exec boil.ContextExecutor, identityID string) (p ProfileView, err error)

ProfileGet ...

type Service

type Service struct {
	SQLDB *sql.DB
	// contains filtered or unexported fields
}

Service ...

func NewService

func NewService(
	avatarRepo AvatarRepo,

	ssoDB *sql.DB,
) Service

NewService ...

func (Service) DeleteAvatar

func (ids Service) DeleteAvatar(ctx context.Context, avatar *AvatarFile) error

DeleteAvatar ...

func (Service) UploadAvatar

func (ids Service) UploadAvatar(ctx context.Context, avatar *AvatarFile) (string, error)

UploadAvatar ...

type WebauthnIdentity

type WebauthnIdentity struct {
	Identity

	WebAuthn []webauthn.Credential
}

func GetEmptyWebauthnIdentity

func GetEmptyWebauthnIdentity(ctx context.Context, identity Identity) (WebauthnIdentity, error)

func GetWebauthnIdentity

func GetWebauthnIdentity(ctx context.Context, exec boil.ContextExecutor, identity Identity) (WebauthnIdentity, error)

func (*WebauthnIdentity) WebAuthnCredentials

func (wid *WebauthnIdentity) WebAuthnCredentials() []webauthn.Credential

func (*WebauthnIdentity) WebAuthnDisplayName

func (wid *WebauthnIdentity) WebAuthnDisplayName() string

func (*WebauthnIdentity) WebAuthnID

func (wid *WebauthnIdentity) WebAuthnID() []byte

func (*WebauthnIdentity) WebAuthnIcon

func (wid *WebauthnIdentity) WebAuthnIcon() string

func (*WebauthnIdentity) WebAuthnName

func (wid *WebauthnIdentity) WebAuthnName() string

Jump to

Keyboard shortcuts

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