audit

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: EUPL-1.2 Imports: 6 Imported by: 0

README

go-audit

Audit API SDK.

Contains common audit configuration, structures and methods for calling audit API.

NB! go-audit is used as a dependency for both audit API and APIs that are making calls to the audit API.

Built with Azugo Go Web Framework

This project is built using the Azugo Go Web Framework, a powerful and flexible framework for building modern web applications in Go. Check out the Azugo GitHub page for more information and documentation.

Usage

  1. Add dependency

    go get -u github.com/edim-test/go-audit
    
  2. Set information about person data access in AuditRequest object.

  3. Use PersonRequest method to make a call to audit API.

Documentation

Index

Constants

View Source
const (
	// Role for third party activities
	RoleThirdParty Role = "THIRD_PARTY"
	// Role for person activities
	RolePerson = "PERSON"
	// Role for admin activities
	RoleAdmin = "ADMIN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	// Successful account registration.
	RegistrationSuccess Action = "reg_success"
	// Failed account registration.
	RegistrationFailure Action = "reg_fail"
	// User successful login to the system.
	ActionLoginSuccess Action = "login_success"
	// User failed login to the system.
	ActionLoginFail Action = "login_fail"
	// User logout from the system.
	ActionLogout Action = "logout"
	// Resource detailed view.
	ActionView Action = "view"
	// Resource search.
	ActionSearch Action = "search"
	// New resource creation.
	ActionCreate Action = "create"
	// Existing resource modification.
	ActionModify Action = "modify"
	// Existing resource deletion.
	ActionDelete Action = "delete"
	// Export person data outside the system.
	ActionExport Action = "export"
	// Request for the person data form outer source.
	ServiceCall Action = "service_call"
)

type Audit

type Audit interface {
	// PersonRequest audits person request.
	PersonRequest(ctx *azugo.Context, request AuditRequest, opts ...http.RequestOption) error
}

Audit interface

func New

func New(configuration *Configuration, sensitiveParams map[string][]string) Audit

New creates a new audit configuration.

type AuditRequest

type AuditRequest struct {
	// ClientID represents audit API caller identifier.
	ClientID string `json:"clientId"`
	// Endpoint represents the accessed endpoint.
	Endpoint *string `json:"endpoint"`
	// Action represents audit action.
	Action string `json:"action"`
	// RequestParameters represents data request parameters.
	RequestParameters *string `json:"requestParameters"`
	// Person represents the accessed endpoint.
	Person *Person `json:"person"`
	// Resources represents identifier ist of the accessed resources.
	Resources *[]Resource `json:"resources"`
	// IPAddress represents IP address of the caller.
	IPAddress *string `json:"ipAddress"`
	// UserAgent represents user agent of the caller.
	UserAgent *string `json:"userAgent"`
}

AuditRequest represents a request to save audit details.

func (*AuditRequest) Validate

func (r *AuditRequest) Validate(validate *validation.Validate) error

type Configuration

type Configuration struct {
	Endpoint string `mapstructure:"endpoint" validate:"required,url"`
}

Configuration is the configuration for the audit middleware.

func (*Configuration) Bind

func (c *Configuration) Bind(prefix string, v *viper.Viper)

Bind configuration section.

func (*Configuration) Validate

func (c *Configuration) Validate(validate *validation.Validate) error

Validate application configuration.

type Person

type Person struct {
	// IdentifierType represents identifier type of the person whose data has been accessed.
	IdentifierType *string `json:"identifierType"`
	// Identifier represents identifier of the person whose data has been accessed.
	Identifier *string `json:"identifier"`
	// GivenName represents given name of the person whose data has been accessed.
	GivenName *string `json:"givenName"`
	// FamilyName represents family name of the person whose data has been accessed.
	FamilyName *string `json:"familyName"`
}

Person represents a person whose data is accessed.

type Resource

type Resource struct {
	// ID represents identifier of the resource.
	ID string `json:"id"`
	// Provider represents provider of the resource, e.g. RTU, CSDD, etc.
	Provider string `json:"provider"`
	// Type represents type of the resource.
	Type string `json:"type"`
}

Resource represents a resource accessed by user.

type Role

type Role string

Jump to

Keyboard shortcuts

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