aboutsummaryrefslogtreecommitdiffstats
path: root/auth.go
blob: 80b3088cb9e6c9ea04a196f0663b59b19b4053e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main

// Basic registered user account structure, for permissions etc.
type User struct {
	// TODO: more specific types for these
	name, pw, email string
}

// Minimal requirements for an authentication backend.
type AuthService interface {
	CheckLogin(name, pw string) error
	NewAccount(name, pw, email string) error
	ChangePassword(name, oldPw, newPw string) error
	GetEmail(name string) (string, error)
	GetUserName(email string) (string, error)
}

// DummyAuth is a "wide-open" implementation of AuthService for development and
// local use. Any username/password is accepted, and a dummy email address is
// always returned.
type DummyAuth bool // TODO: what is the best "dummy" abstract base type?

func (da DummyAuth) CheckLogin(name, pw string) error {
	return nil
}

func (da DummyAuth) NewAccount(name, pw, email string) error {
	return nil
}

func (da DummyAuth) ChangePassword(name, oldPw, newPw string) error {
	return nil
}

func (da DummyAuth) GetEmail(name string) (string, error) {
	return "example@localhost", nil
}

func (da DummyAuth) GetUserName(name string) (string, error) {
	return "common", nil
}