Skip to content
Snippets Groups Projects
Commit 73d0f94b authored by Christian Pointner's avatar Christian Pointner
Browse files

added auth package

parent 0dd3b3aa
No related branches found
No related tags found
No related merge requests found
//
// tank
//
// Import and Playlist Daemon for autoradio project
//
//
// Copyright (C) 2017-2019 Christian Pointner <equinox@helsinki.at>
//
// This file is part of tank.
//
// tank is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// tank is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with tank. If not, see <http://www.gnu.org/licenses/>.
//
package auth
import (
"os"
)
type SessionConfig struct {
AuthKey string `json:"auth-key" yaml:"auth-key" toml:"auth-key"`
EncKey string `json:"enc-key" yaml:"enc-key" toml:"enc-key"`
}
type Config struct {
Sessions SessionConfig `json:"sessions" yaml:"sessions" toml:"sessions"`
}
func (c *Config) ExpandEnv() {
c.Sessions.AuthKey = os.ExpandEnv(c.Sessions.AuthKey)
c.Sessions.EncKey = os.ExpandEnv(c.Sessions.EncKey)
}
//
// tank
//
// Import and Playlist Daemon for autoradio project
//
//
// Copyright (C) 2017-2019 Christian Pointner <equinox@helsinki.at>
//
// This file is part of tank.
//
// tank is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// tank is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with tank. If not, see <http://www.gnu.org/licenses/>.
//
package auth
import (
"errors"
"time"
"github.com/gorilla/securecookie"
)
type Session struct {
sealer *securecookie.SecureCookie
Expires time.Time
Username string
Groups []string
}
func (s *Session) Seal() ([]byte, error) {
return nil, errors.New("not yet implemented")
}
func (s *Session) Unseal([]byte) error {
return errors.New("not yet implemented")
}
func (s *Session) Expired() bool {
return time.Now().Before(s.Expires)
}
......@@ -28,6 +28,7 @@ import (
"errors"
"os"
"gitlab.servus.at/autoradio/tank/auth"
"gitlab.servus.at/autoradio/tank/importer"
"gitlab.servus.at/autoradio/tank/store"
"gopkg.in/yaml.v2"
......@@ -36,11 +37,13 @@ import (
type Config struct {
Store store.Config `json:"store" yaml:"store" toml:"store"`
Importer importer.Config `json:"importer" yaml:"importer" toml:"importer"`
Auth auth.Config `json:"auth" yaml:"auth" toml:"auth"`
}
func (c *Config) ExpandEnv() {
c.Store.ExpandEnv()
c.Importer.ExpandEnv()
c.Auth.ExpandEnv()
}
func ReadConfig(configfile string) (conf *Config, err error) {
......
......@@ -27,3 +27,8 @@ importer:
temp-path: "/tmp"
workers: 10
normalizer: ffmpeg
auth:
sessions:
auth-key: "don't-tell-anyone"
enc-key: "very-very-secret"
......@@ -9,6 +9,7 @@ require (
github.com/gorilla/context v1.1.1
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
github.com/gorilla/securecookie v1.1.1
github.com/jinzhu/gorm v1.9.1
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a
github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment