identity

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 12 Imported by: 0

README

Identity Build Status

Identity is a scalable and decentralized microservice for user identity management.

Prerequisites

NATS Server with JetStream: Refer to the official NATS website for installation instructions.

Dependency on NATS with JetStream

This project relies on NATS Server with JetStream functionality for its operations. Ensure that you have NATS Server with JetStream installed and running before using this project.

For installation instructions and details about NATS Server with JetStream, please refer to the official NATS website (https://nats.io).

Installation

You can install Identity using one of the following methods:

Binary
  1. Clone the repository, navigate to the project directory, build, and install the binary using the following command:

    # clone the repository
    git clone https://github.com/flarexio/identity.git
    
    # navigate to the project directory
    cd identity
    
    # build and install
    go build -o $GOPATH/bin/identity cmd/identity/main.go
    
  2. Copy the config.yaml file to the working directory. You can find an example configuration file in the project repository.

  3. Set the necessary environment variables, such as IDENTITY_PATH and IDENTITY_HTTP_PORT, if required.

  4. Run the installed binary to start the Identity microservice:

    identity
    
Docker
  1. Make sure you have Docker installed and running on your system.

  2. Run the following command to start the Identity microservice using Docker:

  3. Copy the config.yaml file to the working directory. You can find an example configuration file in the project repository.

    docker run -d -p 8080:8080 flarexio/identity:latest
    

    This command starts the Identity microservice in a Docker container, binds it to port 8080, and sets the IDENTITY_PATH and IDENTITY_HTTP_PORT environment variables. It also mounts the config.yaml file into the container at /root/.identity/config.yaml.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProviderNotSupported = errors.New("provider not supported")
	ErrAudienceNotFound     = errors.New("audience not found")
	ErrEmailNotFound        = errors.New("email not found")
	ErrNameNotFound         = errors.New("name not found")
	ErrPictureNotFound      = errors.New("picture not found")
)

Functions

func AddSocialAccountEndpoint

func AddSocialAccountEndpoint(svc Service) endpoint.Endpoint

func EventEndpoint

func EventEndpoint(svc Service) endpoint.Endpoint

func OTPVerifyEndpoint

func OTPVerifyEndpoint(svc Service) endpoint.Endpoint

func RegisterEndpoint

func RegisterEndpoint(svc Service) endpoint.Endpoint

func RegisterPasskeyEndpoint

func RegisterPasskeyEndpoint(svc Service) endpoint.Endpoint

func SignInEndpoint

func SignInEndpoint(svc Service) endpoint.Endpoint

func UserEndpoint added in v1.0.1

func UserEndpoint(svc Service) endpoint.Endpoint

Types

type AddSocialAccountRequest

type AddSocialAccountRequest struct {
	Credential string
	Provider   user.SocialProvider
	Username   string
}

type EndpointSet

type EndpointSet struct {
	Register         endpoint.Endpoint
	SignIn           endpoint.Endpoint
	OTPVerify        endpoint.Endpoint
	AddSocialAccount endpoint.Endpoint
	RegisterPasskey  endpoint.Endpoint
	User             endpoint.Endpoint
}

type EventHandler

type EventHandler interface {
	UserRegisteredHandler(e *user.UserRegisteredEvent) error
	UserActivatedHandler(e *user.UserActivatedEvent) error
	UserSocialAccountAddedHandler(e *user.UserSocialAccountAddedEvent) error
}

type OTPVerifyRequest

type OTPVerifyRequest struct {
	OTP      string
	Username string
}

type RegisterRequest

type RegisterRequest struct {
	Username string
	Name     string
	Email    string
}

type Service

type Service interface {
	Register(username string, name string, email string) (*user.User, error)
	OTPVerify(otp string, username string) (*user.User, error)
	SignIn(credential string, provider user.SocialProvider) (*user.User, error)
	AddSocialAccount(credential string, provider user.SocialProvider, username string) (*user.User, error)
	RegisterPasskey(username string) (*protocol.CredentialCreation, error)
	User(username string) (*user.User, error)
	Handler() (EventHandler, error)
}

func NewService

func NewService(users user.Repository, passkeys passkeys.Service, cfg conf.Providers) Service

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(log *zap.Logger) ServiceMiddleware

type SignInRequest

type SignInRequest struct {
	Credential string
	Provider   user.SocialProvider
}

type SignInResponse

type SignInResponse struct {
	User  *user.User `json:"user"`
	Token *Token     `json:"token"`
}

type Token

type Token struct {
	Token     string    `json:"token"`
	ExpiredAt time.Time `json:"expired_at"`
}

Directories

Path Synopsis
cmd
db
kv
transport

Jump to

Keyboard shortcuts

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