auth

Paddy 2015-06-29 Parent:37a42585660e

175:aa14e29b666f Go to Latest

auth/profile_verification.go

Create Docker image for authd. Create a Dockerfile for authd, which will wrap the compiled Go binary up into a tiny little Docker image. Create an authd/build-docker.sh script that will build the statically-linked binary in a Docker container, so the authd Docker image can use it. We had to include ca-certificates.crt in the Dockerfile, as well, so we could communicate over SSL with things. A wrapper.sh file is included that will pull the JWT_SECRET environment variable out of a kubernetes secrets file, which is a handy wrapper to have. Finally, we added the authd/docker-authd binary to the .hgignore.

History
1 package auth
3 import (
4 "log"
5 "time"
7 "code.secondbit.org/events.hg"
8 )
10 const (
11 EventSystem = "authd"
12 EventModelLogin = "login"
13 EventActionSendVerification = "send_verification"
14 EventTopicLoginVerification = "login_verification"
15 )
17 type loginVerificationNotifier interface {
18 SendLoginVerification(login Login)
19 }
21 type stdoutNotifier struct{}
23 func NewStdoutNotifier() stdoutNotifier {
24 return stdoutNotifier{}
25 }
27 func (s stdoutNotifier) SendLoginVerification(login Login) {
28 log.Printf("Use \"%s\" as the verification code for \"%s\"\n", login.Verification, login.Value)
29 }
31 type nsqNotifier struct {
32 *events.NSQPublisher
33 }
35 func NewNSQNotifier(address string) (*nsqNotifier, error) {
36 p, err := events.NewNSQPublisher(EventSystem+"/"+Version, address)
37 return &nsqNotifier{p}, err
38 }
40 func (n *nsqNotifier) SendLoginVerification(login Login) {
41 evt := events.Event{
42 System: EventSystem,
43 Model: EventModelLogin,
44 ID: login.Value,
45 Action: EventActionSendVerification,
46 Timestamp: time.Now(),
47 Data: map[string]string{
48 "verification": login.Verification,
49 },
50 }
51 err := n.Publish(EventTopicLoginVerification, evt)
52 if err != nil {
53 log.Printf("Error sending event: %#+v\n", err)
54 }
55 }