idp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 15 Imported by: 0

README

idp

Build Status

Identity provider service for authenticating users based on email/password credentials

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Mutation struct {
		ChangePassword func(childComplexity int, email string, newPassword string) int
		CreateUser     func(childComplexity int, input UserInput) int
		DeleteUser     func(childComplexity int, id string) int
		VerifyUser     func(childComplexity int, email string) int
	}

	Query struct {
		GetUser func(childComplexity int, email string) int
		Login   func(childComplexity int, email string, password string) int
	}

	User struct {
		Email         func(childComplexity int) int
		EmailVerified func(childComplexity int) int
		ID            func(childComplexity int) int
		PasswordHash  func(childComplexity int) int
		UpdatedAt     func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type MutationResolver

type MutationResolver interface {
	CreateUser(ctx context.Context, input UserInput) (*User, error)
	DeleteUser(ctx context.Context, id string) (*User, error)
	VerifyUser(ctx context.Context, email string) (*User, error)
	ChangePassword(ctx context.Context, email string, newPassword string) (*User, error)
}

type QueryResolver

type QueryResolver interface {
	GetUser(ctx context.Context, email string) (*User, error)
	Login(ctx context.Context, email string, password string) (*User, error)
}

type Resolver

type Resolver struct {
	DB *database.DB
}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type User

type User struct {
	ID            string    `json:"id" gorm:"primary_key"`
	Email         string    `json:"email" gorm:"unique"`
	PasswordHash  string    `json:"passwordHash"`
	EmailVerified bool      `json:"email_verified"`
	UpdatedAt     time.Time `json:"updated_at"`
}

func (*User) UpdatePassword

func (n *User) UpdatePassword(p string) error

UpdatePassword hash password and assign it to pass word attribute

func (User) ValidatePassword

func (n User) ValidatePassword(p string) error

ValidatePassword compare password hashes

type UserGender

type UserGender string
const (
	UserGenderMale   UserGender = "male"
	UserGenderFemale UserGender = "female"
)

func (UserGender) IsValid

func (e UserGender) IsValid() bool

func (UserGender) MarshalGQL

func (e UserGender) MarshalGQL(w io.Writer)

func (UserGender) String

func (e UserGender) String() string

func (*UserGender) UnmarshalGQL

func (e *UserGender) UnmarshalGQL(v interface{}) error

type UserInput

type UserInput struct {
	Email      string  `json:"email"`
	Password   string  `json:"password"`
	GivenName  *string `json:"given_name"`
	FamilyName *string `json:"family_name"`
	MiddleName *string `json:"middle_name"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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