Auth implemented ish
This commit is contained in:
@@ -4,16 +4,18 @@ import (
|
||||
"io/ioutil"
|
||||
"local/args"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port int
|
||||
DBURI string
|
||||
Database string
|
||||
DriverType string
|
||||
FilePrefix string
|
||||
FileRoot string
|
||||
Auth bool
|
||||
Port int
|
||||
DBURI string
|
||||
Database string
|
||||
DriverType string
|
||||
FilePrefix string
|
||||
FileRoot string
|
||||
Auth bool
|
||||
AuthLifetime time.Duration
|
||||
}
|
||||
|
||||
func New() Config {
|
||||
@@ -32,18 +34,20 @@ func New() Config {
|
||||
as.Append(args.STRING, "database", "database name to use", "db")
|
||||
as.Append(args.STRING, "drivertype", "database driver to use", "boltdb")
|
||||
as.Append(args.BOOL, "auth", "check for authorized access", false)
|
||||
as.Append(args.DURATION, "authlifetime", "duration auth is valid for", time.Hour)
|
||||
|
||||
if err := as.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return Config{
|
||||
Port: as.GetInt("p"),
|
||||
DBURI: as.GetString("dburi"),
|
||||
FilePrefix: as.GetString("fileprefix"),
|
||||
FileRoot: as.GetString("fileroot"),
|
||||
Database: as.GetString("database"),
|
||||
DriverType: as.GetString("drivertype"),
|
||||
Auth: as.GetBool("auth"),
|
||||
Port: as.GetInt("p"),
|
||||
DBURI: as.GetString("dburi"),
|
||||
FilePrefix: as.GetString("fileprefix"),
|
||||
FileRoot: as.GetString("fileroot"),
|
||||
Database: as.GetString("database"),
|
||||
DriverType: as.GetString("drivertype"),
|
||||
Auth: as.GetBool("auth"),
|
||||
AuthLifetime: as.GetDuration("authlifetime"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user