charon

package module
v0.0.0-...-25b80c2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2016 License: AGPL-3.0 Imports: 24 Imported by: 4

README

Charon

A game authentication server, second try...

Installation

Ensure you have a working Go build environment that can compile cgo packages.

go get github.com/AlexMax/charon/...

License

This software has been released under the GNU Affero General Public License. It seemed prudent to start with a license that ensures code freedom, because once you switch to a license that prioritizes developer freedom it's very hard to put the genie back in the bottle. If you have a particular use case in mind where the AGPL would be problematic, however, I am open to alternative licensing arrangements.

I have also vendored Tad Glines' srp library. I feel like the only fair thing to do is to continue to offer this modified library under its original Apache 2.0 license.

Documentation

Index

Constants

View Source
const (
	UserAccessUnverified string = "UNVERIFIED"
	UserAccessUser       string = "USER"
	UserAccessOp         string = "OP"
	UserAccessMaster     string = "MASTER"
	UserAccessOwner      string = "OWNER"
)

User access constants.

View Source
const (
	CharonServerNegotiate uint32 = 0xD003CA01
	CharonAuthNegotiate   uint32 = 0xD003CA10
	CharonServerEphemeral uint32 = 0xD003CA02
	CharonAuthEphemeral   uint32 = 0xD003CA20
	CharonServerProof     uint32 = 0xD003CA03
	CharonAuthProof       uint32 = 0xD003CA30
	CharonUserError       uint32 = 0xD003CAFF
	CharonSessionError    uint32 = 0xD003CAEE
)

Protocol constants.

Variables

View Source
var BaseTemplates = TemplateDefs{
	"home":  TemplateNames{"layout", "header", "home"},
	"login": TemplateNames{"layout", "header", "login"},
}

BaseTemplates contains template definitions for the base routes.

Functions

This section is empty.

Types

type AuthApp

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

AuthApp contains all state for a single instance of the authentication server.

func NewAuthApp

func NewAuthApp(config *Config) (authApp *AuthApp, err error)

NewAuthApp creates a new instance of the auth server app.

func (*AuthApp) ListenAndServe

func (authApp *AuthApp) ListenAndServe(addr string) (err error)

ListenAndServe starts the auth server app.

type AuthEphemeral

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

AuthEphemeral contains an SRP ephemeral value sent from the auth server to the game server.

func (*AuthEphemeral) MarshalBinary

func (packet *AuthEphemeral) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls an AuthEphemeral from binary data.

func (*AuthEphemeral) UnmarshalBinary

func (packet *AuthEphemeral) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls an AuthEphemeral to binary data.

type AuthNegotiate

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

AuthNegotiate is a connection negotiation packet that is sent from the auth server to the game server.

func (*AuthNegotiate) MarshalBinary

func (packet *AuthNegotiate) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls an AuthNegotiate from binary data.

func (*AuthNegotiate) UnmarshalBinary

func (packet *AuthNegotiate) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls an AuthNegotiate to binary data.

type AuthProof

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

AuthProof contains a SRP proof value sent from the auth server to the game server.

func (*AuthProof) MarshalBinary

func (packet *AuthProof) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls an AuthProof from binary data.

func (*AuthProof) UnmarshalBinary

func (packet *AuthProof) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls an AuthProof to binary data.

type Config

type Config struct {
	Database struct {
		Filename string
	}
}

func NewConfig

func NewConfig(iniFile *ini.File) (config *Config)

type Database

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

Database is an instance of our database connection and all necessary state used to manage said instance.

func NewDatabase

func NewDatabase(config *Config) (database *Database, err error)

NewDatabase creates a new Database instance.

func (*Database) AddUser

func (database *Database) AddUser(username string, email string, password string) (err error)

AddUser adds a new user.

func (*Database) FindUser

func (database *Database) FindUser(username string) (user *User, err error)

FindUser tries to find a specific user by name or email address.

func (*Database) Import

func (database *Database) Import(paths ...string) (err error)

Import executes a file containing SQL statements on the loaded database.

func (*Database) LoginUser

func (database *Database) LoginUser(username string, password string) (user *User, err error)

LoginUser tries to log a user in with the passed username and password.

type FormErrors

type FormErrors map[string]string

FormErrors contains a list of errors keyed on their struct names.

type LoginData

type LoginData struct {
	Form   *LoginForm
	Errors FormErrors
}

LoginData contains the context for the Login page.

func NewLoginData

func NewLoginData(req *http.Request) (data *LoginData)

NewLoginData creates a new LoginData that optionally contains prepopulated data from the request.

type LoginForm

type LoginForm struct {
	Login    string
	Password string
}

LoginForm contains the form data for the Login page.

func (*LoginForm) Validate

func (form *LoginForm) Validate(db *Database) (user *User, formErrors FormErrors)

Validate validates the LoginForm.

type Profile

type Profile struct {
	ID                 uint
	User_id            uint
	Clan               string
	Contactinfo        string
	Country            string
	Gravatar           string
	Location           string
	Message            string
	Username           string
	Visible            bool
	Visible_lastplayed bool
}

Profile is representation of the `profile` table in the database.

type ServerEphemeral

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

ServerEphemeral contains an SRP ephemeral value sent from the game server to the auth server.

func (*ServerEphemeral) MarshalBinary

func (packet *ServerEphemeral) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls a ServerEphemeral from binary data.

func (*ServerEphemeral) UnmarshalBinary

func (packet *ServerEphemeral) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls a ServerEphemeral to binary data.

type ServerNegotiate

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

ServerNegotiate is a connection negotiation packet that is sent from the game server to the auth server.

func (*ServerNegotiate) MarshalBinary

func (packet *ServerNegotiate) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls a ServerNegotiate from binary data.

func (*ServerNegotiate) UnmarshalBinary

func (packet *ServerNegotiate) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls a ServerNegotiate to binary data.

type ServerProof

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

ServerProof contains a SRP proof value sent from the game server to the auth server.

func (*ServerProof) MarshalBinary

func (packet *ServerProof) MarshalBinary() (data []byte, err error)

MarshalBinary marshalls a ServerProof from binary data.

func (*ServerProof) UnmarshalBinary

func (packet *ServerProof) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshalls a ServerProof to binary data.

type SessionError

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

func (*SessionError) MarshalBinary

func (packet *SessionError) MarshalBinary() (data []byte, err error)

func (*SessionError) UnmarshalBinary

func (packet *SessionError) UnmarshalBinary(data []byte) (err error)

type SessionErrorType

type SessionErrorType uint8
const (
	SessionErrorTryLater SessionErrorType = iota
	SessionErrorNoExist
	SessionErrorVerifierUnsafe
	SessionErrorAuthFailed
)

type TemplateDefs

type TemplateDefs map[string]TemplateNames

TemplateDefs defines a map of template names for keys and TemplateNames for values

type TemplateNames

type TemplateNames []string

TemplateNames defines a list of templates that exist in the "templates/html" directory, and end with a ".tmpl" extension.

type User

type User struct {
	ID        uint
	Username  string
	Email     string
	Verifier  []byte
	Salt      []byte
	Access    string
	Active    bool
	CreatedAt time.Time `db:"createdAt"`
	UpdatedAt time.Time `db:"updatedAt"`
}

User is a representation of the `User` table in the database.

type WebApp

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

WebApp contains all state for a single instance of the webserver.

func NewWebApp

func NewWebApp(config *Config) (webApp *WebApp, err error)

NewWebApp creates a new instance of the web server app.

func (*WebApp) AddTemplateDefs

func (webApp *WebApp) AddTemplateDefs(tmpls *TemplateDefs) (err error)

AddTemplateDefs takes the passed template definitions, figures out where they exist on the filesystem, parses them, and puts them in the template store for later execution.

func (*WebApp) Home

func (webApp *WebApp) Home(res http.ResponseWriter, req *http.Request)

Home renders the homepage.

func (*WebApp) ListenAndServe

func (webApp *WebApp) ListenAndServe(addr string) (err error)

ListenAndServe has the web server listen on a specific address and port, essentially passing straight through to the http method of the same name.

func (*WebApp) Login

func (webApp *WebApp) Login(ctx context.Context, res http.ResponseWriter, req *http.Request)

Login renders the login page.

func (*WebApp) RenderTemplate

func (webApp *WebApp) RenderTemplate(res http.ResponseWriter, req *http.Request, name string, data interface{})

RenderTemplate renders a named template from the template store that was previously added by AddTemplateDefs.

Directories

Path Synopsis
Package srp provides an implementation of SRP-6a as detailed at: http://srp.stanford.edu/design.html
Package srp provides an implementation of SRP-6a as detailed at: http://srp.stanford.edu/design.html

Jump to

Keyboard shortcuts

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