authware

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 7 Imported by: 0

README

go-sdk

Authware SDK for Go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TamperedCertificate        = fmt.Errorf("server certificate validation failed, tampering with https certificates may have occurred")                                                                                                                                                    // TamperedCertificate is thrown when a TLS certificate cannot be verified, it is only typically returned when the library is out-of-date (which would mean that it would be returned 100% of the time), or a client is tampering with HTTPS responses with an HTTP debugger. Using an HTTP debugger whilst using an Authware application is a security risk as they could potentially bypass authentication entirely by spoofing responses
	BadIdConfiguration         = fmt.Errorf("invalid application configuration, ensure you set the ID and version before calling InitializeApplication")                                                                                                                                    // BadConfiguration is thrown when calling a function with bad data such as a missing ID or version string
	BadHardwareIdConfiguration = fmt.Errorf("invalid application configuration, ensure that you set the HardwareIdentifierFunc to a valid hardware ID fetching function. if you do not want to validate hardware IDs then you need to disable the functionality on the authware dashboard") // BadHardwareIdConfiguration is thrown when the HardwareIdentifierFunc is not set when the application is configured to check user hardware IDs
	AppNotInitialized          = fmt.Errorf("the application must be initialized before calling this function, you can initialize it by calling InitializeApplication")
	AppAlreadyInitialized      = fmt.Errorf("application already initialized") // AppAlreadyInitialized is thrown when InitializeApplication is called when the app is already initialized
)

Functions

This section is empty.

Types

type Api

type Api struct {
	Id   string `json:"id"`   // Id is the identifier used to execute the API and identify it on Authware
	Name string `json:"name"` // Name is the friendly name used to identify the API in a human-readable way
}

Api represents an API attached to an application on Authware

type Application

type Application struct {
	AuthToken                   string        // AuthToken is the current users authorization token
	Version                     string        // Version is the current local version of the application
	Id                          string        // Id is the identifier for your application as appearing on Authware
	Name                        *string       // Name is the name of the application as it appears on Authware
	DateCreated                 *time.Time    // DateCreated is the date and time the application was created
	IsHardwareIdCheckingEnabled *bool         // IsHardwareIdCheckingEnabled is a flag whether a users hardware ID is checked and enforced upon login and any request
	Apis                        *[]Api        // Apis is a list of APIs that are registered on the application
	UserCount                   *int          // UserCount is the amount of users registered on the application
	RequestCount                *int          // RequestCount is the amount of proxied API requests that have taken place on the application, this is not Authware API requests but proxied application API requests
	HardwareIdentifierFunc      func() string // HardwareIdentifierFunc is a function that is called to gather the users hardware identifier, by default this is not set and hardware IDs are ignored at the client level
	// contains filtered or unexported fields
}

Application is the main representation of an Authware application

func NewApplication added in v0.1.7

func NewApplication(id string, version string) (*Application, error)

NewApplication will take in an ID and version string, create an application and automatically initialize it

func (*Application) Authenticate

func (a *Application) Authenticate(username string, password string) error

Authenticate will attempt to authenticate a user based on a username and password, the authentication token will automatically be stored in memory for future authenticated calls

func (*Application) InitializeApplication

func (a *Application) InitializeApplication() error

InitializeApplication will perform one-time initialization tasks for the application. If NewApplication was called to create the type, then this function does not need to be called

func (*Application) Register

func (a *Application) Register(username string, password string, email string, token string) error

Register will create a new user on the application with the provided username, password, email and token, the new user will not be automatically signed in.

type DefaultResponse

type DefaultResponse struct {
	Code    int      `json:"code"`    // Code is the status code returned by the API, this is unrelated to the HTTP status code and contains more specific response data
	Message string   `json:"message"` // Message is the message returned by the API and normally contains human-readable information about the response
	Errors  []string `json:"errors"`  // Errors is the list of human-readable errors caused by the request, typically used for validation issues with user inputs
}

DefaultResponse is the default response format returned by the Authware API, this is globally used across many endpoints and internally used to parse errors

Jump to

Keyboard shortcuts

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