1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-06 03:54:17 +02:00

Added styles to modules. Stylized login module. Added tester

This commit is contained in:
Kris Runzer 2015-01-04 20:41:20 -08:00
parent 3aecf510ad
commit a8a17318db
6 changed files with 183 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package auth
import (
"io"
"net/http"
"path"
@ -9,6 +8,8 @@ import (
"bytes"
"html/template"
"github.com/go-authboss/authboss"
)
@ -39,7 +40,16 @@ func (a *Auth) Initialize(c authboss.Config) (err error) {
return err
}
}
a.loginPage = bytes.NewBuffer(data)
var tpl *template.Template
if tpl, err = template.New("login.html").Parse(string(data)); err != nil {
return err
} else {
a.loginPage = &bytes.Buffer{}
if err = tpl.Execute(a.loginPage, nil); err != nil {
return err
}
}
a.routes = authboss.Routes{
path.Join(c.MountPath, "login"): a.loginHandler,
@ -55,6 +65,10 @@ func (a *Auth) Routes() authboss.Routes {
return a.routes
}
func (a *Auth) Style() ([]byte, error) {
return views_login_css_bytes()
}
func (a *Auth) Storage() {
}
@ -62,7 +76,7 @@ func (a *Auth) Storage() {
func (a *Auth) loginHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case methodGET:
io.Copy(w, a.loginPage)
w.Write(a.loginPage.Bytes())
case methodPOST:
// TODO
default:

View File

@ -61,7 +61,27 @@ func (fi bindata_file_info) Sys() interface{} {
return nil
}
var _views_login_tpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x7c\x90\xcd\x8d\xc3\x20\x10\x85\xef\x2b\x6d\x0f\x68\x1a\xa0\x01\xa0\x82\x3d\xec\x65\x0b\x80\x85\xc4\x48\xc0\x20\x33\x28\x71\xf7\x01\x1b\xff\x1c\xa2\xf8\x60\xde\xd3\xbc\xe1\x13\x4f\x4c\x14\x83\xfa\xfe\x12\x06\xed\xd2\xcf\x1b\xce\x91\x45\x47\x13\x5a\x09\x19\x0b\x01\xd3\xff\xe4\x31\x49\xe0\x01\xef\x3e\x41\x4b\xb1\xf6\x89\xa0\x8d\x0b\xac\xe5\x25\xd4\xe2\xe6\xa4\xa3\x03\xf5\x37\x94\xe0\xeb\x78\xcf\xfa\x94\x2b\x31\x5a\xb2\x93\x40\xee\xd9\x2e\xf5\xf6\xb2\xc6\xfa\xff\xea\xf9\x1b\x48\xd6\xa5\x3c\x70\xb6\xa0\x7e\x87\xfa\x00\x39\xc2\x2b\xe8\x74\x1b\xe8\xf4\x07\xc8\x54\x22\x4c\x63\xbb\x54\x13\x3d\x81\xfa\xe9\x0f\x16\x7c\x9b\xf5\x76\x78\xaf\x67\x15\x7b\x5f\x7c\x14\xf8\x0a\x00\x00\xff\xff\x11\x71\x5f\xad\x49\x01\x00\x00")
var _views_login_css = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x94\x55\xdd\x4e\xe3\x3a\x10\xbe\x47\xe2\x1d\x2c\xa1\x23\x40\x6a\x82\x73\x5a\x5a\x48\x85\xce\xd9\x9b\x7d\x80\xbd\x5d\x71\xe1\xc4\x4e\x32\xc2\xf1\x58\xb6\x4b\x0b\x2b\xde\x7d\x9d\xe6\xa7\x49\x9a\x52\xa8\xdb\x1b\xcf\x8f\x67\xbe\xf9\xe6\xeb\xff\x50\x6a\x34\x8e\x6c\x8c\xbc\x29\x9c\xd3\xf1\xdd\x5d\x86\xca\xd9\x30\x47\xcc\xa5\x60\x1a\x6c\x98\x62\x79\x97\x5a\xfb\x5f\xc6\x4a\x90\x6f\x4f\xbf\x30\x41\x87\xf1\x82\xd2\x59\x44\xe9\xed\xfa\xf2\xe2\xf2\x22\x41\xfe\x46\xfe\x5c\x5e\x10\xff\xa9\xe2\x83\xda\x37\x26\xd7\xb5\xf7\xf5\x8c\x58\xa6\x6c\x60\x85\x81\xcc\x47\x7c\x54\x41\xa1\xc4\x1c\x54\x90\x32\xc3\xdb\x58\xcd\x38\x07\x95\xc7\x64\x41\xf5\x6e\x5d\xdf\x6d\x81\xbb\x22\x26\xff\xae\x16\xdd\x55\xc2\xd2\x97\xdc\xe0\x46\xf1\x20\x45\x89\x26\x26\x57\x3f\x57\xd5\x69\xec\x25\x33\x3e\x73\x4c\x28\x61\x1b\x87\x24\x3a\x24\x4b\xd0\x70\x61\x02\xc3\x38\x6c\xac\x4f\xda\x33\xec\x02\x5b\x30\x8e\x5b\x1f\xa6\x77\x95\x65\xff\x33\x79\xc2\x6e\xe8\x8c\x34\xdf\x70\x7e\xdb\x04\xe0\xab\x30\x99\xac\xdc\x0b\xe0\x5c\xa8\xa9\xae\x8a\x68\x00\xca\x56\x40\x5e\xb8\xd8\xd7\x43\x9b\x24\x4e\xec\x5c\xc0\x24\xe4\xbe\xd8\x54\x28\x27\xcc\xba\xe7\x6f\xe1\x5d\xf8\x1a\xc3\xb9\x28\xa7\xb2\x83\xd2\x1b\xf7\xdb\xbd\x69\xf1\x64\x37\x49\x09\xee\xb9\x7d\xad\x81\xcc\xbf\xf3\x4f\x93\x8f\x83\xd5\x92\xf9\x81\x24\x12\xd3\x97\x01\x4c\x81\x1f\x90\xc3\x32\xee\xc3\xa4\xd1\x82\x03\xf4\x55\x19\x21\x99\x83\x57\x71\xa6\x80\xaa\x91\xe7\x59\xff\x46\x33\x6b\xb7\x1e\xed\xae\xa8\xa2\xe9\x7e\x71\x98\x63\xaf\xcb\x68\x39\x1e\x78\xaf\xfa\xd3\x85\x7a\x4c\x93\x17\xf0\x18\x6a\x2d\x98\x61\x2a\xf5\xa9\x14\x2a\x71\x44\x14\x4f\x91\x2c\xcb\x06\x2c\xf0\x89\xfc\x80\x2d\x4a\xe0\xe4\x8a\x3f\x56\x67\xc8\x12\x87\x7a\xe0\x93\xd2\xea\xac\x47\x54\xa5\xe4\x61\xc8\x22\x78\xdf\xdf\x37\x49\xfc\x55\x5b\x6b\x89\xef\xc1\x49\x8f\xb3\xe8\xc6\x45\x45\xb9\x69\x8c\x6b\x5b\x8b\xf4\x44\x7b\xc9\x63\x75\x3e\x6f\x8f\xd1\xea\x1c\x15\xdb\x2c\x05\x28\x2b\x9c\x6f\x36\x1a\x2e\xc6\xfe\x84\xd1\xed\x68\x1e\xdf\x8f\xfc\x5e\x44\x0f\xad\xb6\xeb\xaf\xec\x52\x34\xe2\x5e\x27\x53\x3f\x0c\x30\x39\x56\xa9\xa3\xc5\x5d\x75\x8b\xdb\x92\x79\x7e\xa0\xed\x11\x21\xfa\x13\xad\x17\x74\x3c\xa0\x03\x8f\x5b\x19\x3b\x70\x74\xdf\x4e\xa7\x48\x7b\x28\x4e\x00\x77\x2c\x86\x0b\xfe\x48\xb3\xf1\xca\xd6\x25\x4c\x33\xe5\x50\xc8\xb9\x67\xe7\x9f\x3c\x3b\xbf\x5f\x31\xf1\x30\xc5\x65\x36\x18\x12\x17\x29\x1a\x56\xeb\x4b\x6f\x59\xdb\x34\xcb\xe5\x72\x0a\xfc\xc5\x79\xd5\xec\x54\x0e\x94\x04\x25\x82\xbe\xd8\xa1\x66\x29\x38\x6f\xa3\x61\x9b\xde\x79\xc1\x68\x75\xae\x31\x13\xc1\xac\xf0\x2e\xf7\x76\xb2\x8d\x21\x7a\x5d\xca\x68\xe4\x5c\x08\xa9\x4f\x6b\xf1\x97\x88\x5a\xff\x33\x7d\xfc\x0d\x00\x00\xff\xff\x8c\x99\xe5\x66\xa0\x07\x00\x00")
func views_login_css_bytes() ([]byte, error) {
return bindata_read(
_views_login_css,
"views/login.css",
)
}
func views_login_css() (*asset, error) {
bytes, err := views_login_css_bytes()
if err != nil {
return nil, err
}
info := bindata_file_info{name: "views/login.css", size: 1952, mode: os.FileMode(438), modTime: time.Unix(1420431129, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _views_login_tpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x52\x41\x4e\x85\x30\x10\xdd\x9b\x78\x87\x66\x5c\x7f\x1b\xf7\x85\xa5\xab\xbf\x30\x26\x1e\xa0\xc0\x7c\xda\x58\x28\xce\xb4\x5f\xd9\x79\x16\x8f\xe6\x49\x2c\xd8\xa2\xc4\x98\x7c\x36\xbc\xe9\x3c\xde\x3c\xde\x54\x99\x30\xb8\xfa\xfa\x4a\xa4\x47\x39\x3b\x3e\x8b\x30\x4f\x58\x41\xc0\xb7\x20\x5b\x66\x10\x84\xae\x02\x0e\xb3\x43\x36\x88\x01\x84\x21\x3c\x55\x20\x75\x0c\xa6\xf1\xcc\xb7\x2b\x4b\x26\x0d\xd5\xf8\x6e\x5e\xde\x9d\x3d\x8b\xd6\x69\xe6\x0a\x9c\xef\xed\x78\x68\x35\x75\x50\xa6\x98\xbb\xfa\xe8\xfb\x83\x1d\x95\x4c\x50\x35\x54\x1a\x27\x4f\x43\xc6\x6b\x6d\xc7\x29\x86\x5f\x7e\x40\x8c\x7a\x48\x38\x32\xd2\x82\x40\x4c\x4e\xb7\x68\xbc\xeb\x90\x2a\x78\xda\x8e\x09\x5f\xa2\x25\xec\xd2\x67\x14\x11\xfe\xd3\x9c\x92\xc3\x57\x9f\x9c\x65\xdd\x9f\x7a\xa7\xfb\xb0\x1d\x5f\xa8\xcb\xb1\x19\xec\xe6\x76\x4d\x00\x76\x79\x88\xef\x54\x0a\xef\xac\x5d\x4c\xc4\xe3\x4a\x2c\x61\xc8\x9c\x46\x2e\xff\x44\x6a\xd0\x4d\x3b\x07\x3a\x2f\xe6\x06\xea\x47\xec\x2d\x07\x24\x25\x75\x2d\x3e\xdf\x3f\x76\xcd\x7b\x4f\xbd\x0f\xa2\xfc\xd5\xc2\x29\x23\xd3\x90\x65\x7d\xb2\xec\x51\xe6\xcb\xf1\x15\x00\x00\xff\xff\x9b\xc0\xd6\xae\x25\x02\x00\x00")
func views_login_tpl_bytes() ([]byte, error) {
return bindata_read(
@ -76,7 +96,7 @@ func views_login_tpl() (*asset, error) {
return nil, err
}
info := bindata_file_info{name: "views/login.tpl", size: 329, mode: os.FileMode(438), modTime: time.Unix(1420331148, 0)}
info := bindata_file_info{name: "views/login.tpl", size: 549, mode: os.FileMode(438), modTime: time.Unix(1420432724, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -122,6 +142,7 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"views/login.css": views_login_css,
"views/login.tpl": views_login_tpl,
}
@ -166,6 +187,7 @@ type _bintree_t struct {
}
var _bintree = &_bintree_t{nil, map[string]*_bintree_t{
"views/login.css": &_bintree_t{views_login_css, map[string]*_bintree_t{}},
"views/login.tpl": &_bintree_t{views_login_tpl, map[string]*_bintree_t{}},
}}

92
auth/views/login.css Normal file
View File

@ -0,0 +1,92 @@
@import url(http://fonts.googleapis.com/css?family=Roboto:400,100);
body {
font-family: 'Roboto', sans-serif;
}
.login-card {
padding: 40px;
width: 274px;
background-color: #F7F7F7;
margin: 0 auto 10px;
border-radius: 2px;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.login-card h1 {
font-weight: 100;
text-align: center;
font-size: 2.3em;
}
.login-card input[type=submit] {
width: 100%;
display: block;
margin-bottom: 10px;
position: relative;
}
.login-card input[type=text], input[type=password] {
height: 44px;
font-size: 16px;
width: 100%;
margin-bottom: 10px;
-webkit-appearance: none;
background: #fff;
border: 1px solid #d9d9d9;
border-top: 1px solid #c0c0c0;
padding: 0 8px;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.login-card input[type=text]:hover, input[type=password]:hover {
border: 1px solid #b9b9b9;
border-top: 1px solid #a0a0a0;
-moz-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.login {
text-align: center;
font-size: 14px;
font-family: 'Arial', sans-serif;
font-weight: 700;
height: 36px;
padding: 0 8px;
}
.login-submit {
border: 0px;
color: #fff;
text-shadow: 0 1px rgba(0,0,0,0.1);
background-color: #4d90fe;
}
.login-submit:hover {
border: 0px;
text-shadow: 0 1px rgba(0,0,0,0.3);
background-color: #357ae8;
}
.login-card a {
text-decoration: none;
color: #666;
font-weight: 400;
text-align: center;
display: inline-block;
opacity: 0.6;
transition: opacity ease 0.5s;
}
.login-card a:hover {
opacity: 1;
}
.login-help {
width: 100%;
text-align: center;
font-size: 12px;
}

View File

@ -1,11 +1,16 @@
<html>
<link type="text/css" rel="stylesheet" href="/authboss.css" />
<body>
<form method="post" action="/login">
<label for="username">Username</label>
<input type="text" id="username" name="username" />
<label for="password">Password</label>
<input type="password" id="password" name="password" />
<button type="submit">Login</button>
</form>
<div class="login-card">
<h1>Log-in</h1><br>
<form>
<input type="text" name="username" placeholder="Username" required="true">
<input type="password" name="password" placeholder="Password" required="true">
<input type="submit" name="login" class="login login-submit" value="Login">
</form>
<div class="login-help">
<a href="#">Register</a> • <a href="#">Forgot Password</a>
</div>
</body>
</html>

View File

@ -9,6 +9,7 @@ type Routes map[string]http.HandlerFunc
type Modularizer interface {
Initialize(Config) error
Routes() Routes
Style() ([]byte, error)
Storage()
}

37
tester/tester.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"net/http"
"log"
"io"
"bytes"
"github.com/go-authboss/authboss"
"github.com/go-authboss/authboss/auth"
)
func main() {
a := &auth.Auth{}
a.Initialize(authboss.Config{
MountPath: "/",
})
mux := http.NewServeMux()
for path, fn := range a.Routes() {
mux.HandleFunc(path, fn)
}
mux.HandleFunc("/authboss.css", func(w http.ResponseWriter, r *http.Request) {
if b, err := a.Style(); err != nil {
log.Panicln(err)
} else {
io.Copy(w, bytes.NewBuffer(b))
}
})
http.ListenAndServe("localhost:8080", mux)
}