fabric8-wit: github.com/fabric8-services/fabric8-wit/account Index | Files

package account

import "github.com/fabric8-services/fabric8-wit/account"

Package account contains the code to manage users and integrate authenthication functionalities from other identity providers.

Index

Package Files

context_information.go doc.go identity.go init_tenant.go user.go

Constants

const (
    // KeycloakIDP is the name of the main Keycloak Identity Provider
    KeycloakIDP string = "kc"
)

func CleanTenant Uses

func CleanTenant(ctx context.Context, config tenantConfig) error

CleanTenant cleans out a tenant in oso.

func IdentityFilterByID Uses

func IdentityFilterByID(identityID uuid.UUID) func(db *gorm.DB) *gorm.DB

IdentityFilterByID is a gorm filter for Identity ID.

func IdentityFilterByProfileURL Uses

func IdentityFilterByProfileURL(profileURL string) func(db *gorm.DB) *gorm.DB

IdentityFilterByProfileURL is a gorm filter by 'profile_url'

func IdentityFilterByProviderType Uses

func IdentityFilterByProviderType(providerType string) func(db *gorm.DB) *gorm.DB

IdentityFilterByProviderType is a gorm filter by 'provider_type'

func IdentityFilterByRegistrationCompleted Uses

func IdentityFilterByRegistrationCompleted(registrationCompleted bool) func(db *gorm.DB) *gorm.DB

IdentityFilterByRegistrationCompleted is a gorm filter by 'registration_completed'

func IdentityFilterByUserID Uses

func IdentityFilterByUserID(userID uuid.UUID) func(db *gorm.DB) *gorm.DB

IdentityFilterByUserID is a gorm filter for a Belongs To relationship.

func IdentityFilterByUsername Uses

func IdentityFilterByUsername(username string) func(db *gorm.DB) *gorm.DB

IdentityFilterByUsername is a gorm filter by 'username'

func IdentityWithUser Uses

func IdentityWithUser() func(db *gorm.DB) *gorm.DB

IdentityWithUser is a gorm filter for preloading the User relationship.

func InitTenant Uses

func InitTenant(ctx context.Context, config tenantConfig) error

InitTenant creates a new tenant service in oso

func NewCleanTenant Uses

func NewCleanTenant(config tenantConfig) func(context.Context) error

NewCleanTenant creates a new tenant service in oso

func NewInitTenant Uses

func NewInitTenant(config tenantConfig) func(context.Context) error

NewInitTenant creates a new tenant service in oso

func NewShowTenant Uses

func NewShowTenant(config tenantConfig) func(context.Context) (*tenant.TenantSingle, error)

NewShowTenant view an existing tenant in oso

func NewUpdateTenant Uses

func NewUpdateTenant(config tenantConfig) func(context.Context) error

NewUpdateTenant creates a new tenant service in oso

func ShowTenant Uses

func ShowTenant(ctx context.Context, config tenantConfig) (*tenant.TenantSingle, error)

ShowTenant fetches the current tenant state.

func UpdateTenant Uses

func UpdateTenant(ctx context.Context, config tenantConfig) error

UpdateTenant updates excisting tenant in oso

func UserFilterByEmail Uses

func UserFilterByEmail(email string) func(db *gorm.DB) *gorm.DB

UserFilterByEmail is a gorm filter for User ID.

func UserFilterByID Uses

func UserFilterByID(userID uuid.UUID) func(db *gorm.DB) *gorm.DB

UserFilterByID is a gorm filter for User ID.

type ContextInformation Uses

type ContextInformation map[string]interface{}

ContextInformation a map for context information

func (ContextInformation) Equal Uses

func (f ContextInformation) Equal(u convert.Equaler) bool

Equal returns true if two ContextInformation objects are equal; otherwise false is returned.

func (*ContextInformation) Scan Uses

func (f *ContextInformation) Scan(src interface{}) error

func (ContextInformation) Value Uses

func (f ContextInformation) Value() (driver.Value, error)

type GormIdentityRepository Uses

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

GormIdentityRepository is the implementation of the storage interface for Identity.

func NewIdentityRepository Uses

func NewIdentityRepository(db *gorm.DB) *GormIdentityRepository

NewIdentityRepository creates a new storage type.

func (*GormIdentityRepository) CheckExists Uses

func (m *GormIdentityRepository) CheckExists(ctx context.Context, id string) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormIdentityRepository) Create Uses

func (m *GormIdentityRepository) Create(ctx context.Context, model *Identity) error

Create creates a new record.

func (*GormIdentityRepository) Delete Uses

func (m *GormIdentityRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a single record.

func (*GormIdentityRepository) First Uses

func (m *GormIdentityRepository) First(funcs ...func(*gorm.DB) *gorm.DB) (*Identity, error)

First returns the first Identity element that matches the given criteria

func (*GormIdentityRepository) IsValid Uses

func (m *GormIdentityRepository) IsValid(ctx context.Context, id uuid.UUID) bool

IsValid returns true if the identity exists

func (*GormIdentityRepository) List Uses

func (m *GormIdentityRepository) List(ctx context.Context) ([]Identity, error)

List return all user identities

func (*GormIdentityRepository) Load Uses

func (m *GormIdentityRepository) Load(ctx context.Context, id uuid.UUID) (*Identity, error)

Load returns a single Identity as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*GormIdentityRepository) Lookup Uses

func (m *GormIdentityRepository) Lookup(ctx context.Context, username, profileURL, providerType string) (*Identity, error)

Lookup looks for an existing identity with the given `profileURL` or creates a new one

func (*GormIdentityRepository) Query Uses

func (m *GormIdentityRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Identity, error)

Query expose an open ended Query model

func (*GormIdentityRepository) Save Uses

func (m *GormIdentityRepository) Save(ctx context.Context, model *Identity) error

Save modifies a single record.

func (*GormIdentityRepository) Search Uses

func (m *GormIdentityRepository) Search(ctx context.Context, q string, start int, limit int) ([]Identity, int, error)

Search searches for Identites where FullName like %q% or users.email like %q% or users.username like %q%

func (*GormIdentityRepository) TableName Uses

func (m *GormIdentityRepository) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type GormUserRepository Uses

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

GormUserRepository is the implementation of the storage interface for User.

func (*GormUserRepository) CheckExists Uses

func (m *GormUserRepository) CheckExists(ctx context.Context, id string) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormUserRepository) Create Uses

func (m *GormUserRepository) Create(ctx context.Context, u *User) error

Create creates a new record.

func (*GormUserRepository) Delete Uses

func (m *GormUserRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a single record.

func (*GormUserRepository) List Uses

func (m *GormUserRepository) List(ctx context.Context) ([]User, error)

List return all users

func (*GormUserRepository) Load Uses

func (m *GormUserRepository) Load(ctx context.Context, id uuid.UUID) (*User, error)

Load returns a single User as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*GormUserRepository) Query Uses

func (m *GormUserRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]User, error)

Query expose an open ended Query model

func (*GormUserRepository) Save Uses

func (m *GormUserRepository) Save(ctx context.Context, model *User) error

Save modifies a single record

func (*GormUserRepository) TableName Uses

func (m *GormUserRepository) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type Identity Uses

type Identity struct {
    gormsupport.Lifecycle
    // This is the ID PK field. For identities provided by Keycloak this ID equals to the Keycloak. For other types of IDP (github, oso, etc) this ID is generated automaticaly
    ID  uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
    // The username of the Identity
    Username string
    // Whether username has been updated.
    RegistrationCompleted bool `gorm:"column:registration_completed"`
    // ProviderType The type of provider, such as "keycloak", "github", "oso", etc
    ProviderType string `gorm:"column:provider_type"`
    // the URL of the profile on the remote work item service
    ProfileURL *string `gorm:"column:profile_url"`
    // Link to User
    UserID NullUUID `sql:"type:uuid"`
    User   User
}

Identity describes a federated identity provided by Identity Provider (IDP) such as Keycloak, GitHub, OSO, etc. One User account can have many Identities

func (Identity) GetETagData Uses

func (m Identity) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Identity) GetLastModified Uses

func (m Identity) GetLastModified() time.Time

GetLastModified returns the last modification time

func (Identity) TableName Uses

func (m Identity) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type IdentityRepository Uses

type IdentityRepository interface {
    repository.Exister
    Load(ctx context.Context, id uuid.UUID) (*Identity, error)
    Create(ctx context.Context, identity *Identity) error
    Lookup(ctx context.Context, username, profileURL, providerType string) (*Identity, error)
    Save(ctx context.Context, identity *Identity) error
    Delete(ctx context.Context, id uuid.UUID) error
    Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Identity, error)
    List(ctx context.Context) ([]Identity, error)
    IsValid(context.Context, uuid.UUID) bool
    Search(ctx context.Context, q string, start int, limit int) ([]Identity, int, error)
}

IdentityRepository represents the storage interface.

type NullUUID Uses

type NullUUID struct {
    UUID  uuid.UUID
    Valid bool
}

NullUUID can be used with the standard sql package to represent a UUID value that can be NULL in the database

func (*NullUUID) Scan Uses

func (u *NullUUID) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (NullUUID) Value Uses

func (u NullUUID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type User Uses

type User struct {
    gormsupport.Lifecycle
    ID                 uuid.UUID          `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
    Email              string             `sql:"unique_index"`                                            // This is the unique email field
    FullName           string             // The fullname of the User
    ImageURL           string             // The image URL for the User
    Bio                string             // The bio of the User
    URL                string             // The URL of the User
    Company            string             // The (optional) Company of the User
    Identities         []Identity         // has many Identities from different IDPs
    ContextInformation ContextInformation `sql:"type:jsonb"` // context information of the user activity
}

User describes a User account. A few identities can be assosiated with one user account

func (User) GetETagData Uses

func (m User) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (User) GetLastModified Uses

func (m User) GetLastModified() time.Time

GetLastModified returns the last modification time

func (User) TableName Uses

func (m User) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type UserRepository Uses

type UserRepository interface {
    repository.Exister
    Load(ctx context.Context, ID uuid.UUID) (*User, error)
    Create(ctx context.Context, u *User) error
    Save(ctx context.Context, u *User) error
    List(ctx context.Context) ([]User, error)
    Delete(ctx context.Context, ID uuid.UUID) error
    Query(funcs ...func(*gorm.DB) *gorm.DB) ([]User, error)
}

UserRepository represents the storage interface.

func NewUserRepository Uses

func NewUserRepository(db *gorm.DB) UserRepository

NewUserRepository creates a new storage type.

Package account imports 23 packages (graph) and is imported by 22 packages. Updated 2017-10-23. Refresh now. Tools for package owners.