Verified Commit 5c5ccdcc authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

Merge branch 'master' into ci-workflow

parents 338c4d7e 4ab6b8f5
Pipeline #8543 passed with stages
in 2 minutes and 53 seconds
......@@ -2,7 +2,7 @@ package main
import (
"github.com/BurntSushi/toml"
"gitlab.switch.ch/memoriav/memobase-2020/streaming-server/memostream"
"gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/memostream"
"log"
"time"
)
......@@ -44,7 +44,6 @@ type Config struct {
CertPEM string
KeyPEM string
Addr string
Basedir string
StaticDir string
UrlPrefix string
CmdPrefix string
......
......@@ -5,7 +5,7 @@ import (
"database/sql"
"flag"
_ "github.com/go-sql-driver/mysql"
"gitlab.switch.ch/memoriav/memobase-2020/streaming-server/memostream"
"gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/memostream"
"io"
"log"
"os"
......@@ -93,7 +93,6 @@ func main() {
fm := memostream.NewFileMapper(mapping)
srv := memostream.NewServer(
config.Basedir,
config.UrlPrefix,
config.CmdPrefix,
config.IIIF.Prefix,
......
......@@ -4,7 +4,6 @@ accesslog = "" # http access log file
addr = "localhost:82"
certpem = "" # tls client certificate file in PEM format
keypem = "" # tls client key file in PEM format
basedir = "c:/temp/"
staticdir = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/streaming-server/static/"
staticprefix = "/static/"
urlprefix = "/memo/" # prefix for accessing signature based content
......
......@@ -147,12 +147,19 @@ func NewJWT(secret string, subject string, alg string, valid int64, domain strin
return "", emperror.Wrapf(err, "invalid signing method %s", alg)
}
exp := time.Now().Unix() + valid
token := jwt.NewWithClaims(signingMethod, jwt.MapClaims{
claims := jwt.MapClaims{
"sub": strings.ToLower(subject),
"exp": exp,
"aud": domain,
"iss": issuer,
})
}
// keep jwt short, no empty fields
if domain != "" {
claims["aud"] = domain
}
if issuer != "" {
claims["iss"] = issuer
}
token := jwt.NewWithClaims(signingMethod, claims)
// log.Println("NewJWT( ", secret, ", ", subject, ", ", exp)
tokenString, err = token.SignedString([]byte(secret))
return tokenString, err
......
......@@ -32,7 +32,6 @@ type Sig struct {
type memoServer struct {
srv *http.Server
baseDir string
staticDir string
urlPrefix string
cmdPrefix string
......@@ -56,7 +55,6 @@ type memoServer struct {
}
func NewServer(
basedir,
urlPrefix,
cmdPrefix,
iiifPrefix,
......@@ -85,7 +83,6 @@ func NewServer(
}
return &memoServer{
//mh: NewMemoHandler(baseDir, urlPrefix, resolver, jwtSecret, log, errorTemplate),
baseDir: basedir,
resolver: resolver,
mapping: mapping,
urlPrefix: urlPrefix,
......
......@@ -43,7 +43,7 @@ func (ms *memoServer) proxyIIIF(req *http.Request, writer http.ResponseWriter, s
newtoken := "open"
if !public {
sub := signature // ms.iiifJwtSubPrefix + filePath
newtoken, err = NewJWT(ms.jwtSecret, ms.jwtAlg[0], sub, 7200, "default", "default")
newtoken, err = NewJWT(ms.jwtSecret, ms.jwtAlg[0], sub, 7200, "", "")
if err != nil {
return emperror.Wrapf(err, "Error creating access token")
}
......
......@@ -75,7 +75,7 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) {
}
newtoken := ""
if me.Access != Media_Public {
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "default", "default")
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "", "")
if err != nil {
ms.DoPanicf(w, http.StatusInternalServerError, "Cannot create token: %v", err)
return
......@@ -107,7 +107,7 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) {
}
newtoken := ""
if me.Access != Media_Public {
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "default", "default")
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "", "")
if err != nil {
ms.DoPanicf(w, http.StatusInternalServerError, "Cannot create token: %v", err)
return
......@@ -138,7 +138,7 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) {
}
newtoken := ""
if me.Access != Media_Public {
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "default", "default")
newtoken, err = NewJWT(ms.jwtSecret, signature, ms.jwtAlg[0], 7200, "", "")
if err != nil {
ms.DoPanicf(w, http.StatusInternalServerError, "Cannot create token: %v", err)
return
......
......@@ -28,8 +28,8 @@ SET time_zone = "+00:00";
-- Tabellenstruktur für Tabelle `banner`
--
CREATE TABLE `banner` (
`sig` varchar(256) COLLATE utf8_bin NOT NULL,
CREATE TABLE IF NOT EXISTS `banner` (
`sig` varchar(255) COLLATE utf8_bin NOT NULL,
`error` tinyint(1) NOT NULL DEFAULT 0,
`mimetype` varchar(128) COLLATE utf8_bin DEFAULT NULL,
`width` int(11) DEFAULT NULL,
......@@ -43,10 +43,10 @@ CREATE TABLE `banner` (
-- Tabellenstruktur für Tabelle `entities`
--
CREATE TABLE `entities` (
CREATE TABLE IF NOT EXISTS `entities` (
`sig` varchar(255) COLLATE utf8_bin NOT NULL,
`uri` varchar(1024) COLLATE utf8_bin NOT NULL,
`manifest` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'NULL',
`manifest` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
`access` enum('closed','public') COLLATE utf8_bin NOT NULL,
`proto` enum('file','redirect','proxy') COLLATE utf8_bin NOT NULL,
`status` enum('ok','error','new') COLLATE utf8_bin NOT NULL DEFAULT 'new',
......@@ -62,7 +62,7 @@ CREATE TABLE `entities` (
-- Stellvertreter-Struktur des Views `entities_metadata`
-- (Siehe unten für die tatsächliche Ansicht)
--
CREATE TABLE `entities_metadata` (
CREATE TABLE IF NOT EXISTS `entities_metadata` (
`sig` varchar(255)
,`uri` varchar(1024)
,`access` enum('closed','public')
......@@ -82,7 +82,7 @@ CREATE TABLE `entities_metadata` (
-- Tabellenstruktur für Tabelle `metadata`
--
CREATE TABLE `metadata` (
CREATE TABLE IF NOT EXISTS `metadata` (
`sig` varchar(255) COLLATE utf8_bin NOT NULL,
`error` tinyint(1) NOT NULL DEFAULT 0,
`mimetype` varchar(128) COLLATE utf8_bin DEFAULT NULL,
......@@ -100,7 +100,7 @@ CREATE TABLE `metadata` (
--
DROP TABLE IF EXISTS `entities_metadata`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`ba14ns21404.fhnw.ch` SQL SECURITY DEFINER VIEW `entities_metadata` AS select `e`.`sig` AS `sig`,`e`.`uri` AS `uri`,`e`.`access` AS `access`,`e`.`proto` AS `proto`,`e`.`status` AS `status`,`m`.`error` AS `error`,`m`.`mimetype` AS `mimetype`,`m`.`width` AS `width`,`m`.`height` AS `height`,`m`.`metadata` AS `metadata`,`m`.`modificationtime` AS `modificationtime` from (`entities` `e` left join `metadata` `m` on(`m`.`sig` = `e`.`sig`)) ;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`ba14ns21404.fhnw.ch` SQL SECURITY DEFINER VIEW IF NOT EXISTS `entities_metadata` AS select `e`.`sig` AS `sig`,`e`.`uri` AS `uri`,`e`.`access` AS `access`,`e`.`proto` AS `proto`,`e`.`status` AS `status`,`m`.`error` AS `error`,`m`.`mimetype` AS `mimetype`,`m`.`width` AS `width`,`m`.`height` AS `height`,`m`.`metadata` AS `metadata`,`m`.`modificationtime` AS `modificationtime` from (`entities` `e` left join `metadata` `m` on(`m`.`sig` = `e`.`sig`)) ;
--
-- Indizes der exportierten Tabellen
......
......@@ -3,7 +3,7 @@ package main
import (
"context"
"flag"
"gitlab.switch.ch/memoriav/memobase-2020/streaming-server/memostream"
"gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/memostream"
"io"
"log"
"os"
......
......@@ -5,7 +5,7 @@ addr = "localhost:83"
certpem = "" # tls client certificate file in PEM format
keypem = "" # tls client key file in PEM format
jwtkey = "swordfish"
jwtissuer = "tokenService"
jwtissuer = ""
jwtalg = "HS384" # "hs256" "hs384" "hs512" "es256" "es384" "es512" "ps256" "ps384" "ps512"
jwtlifetime = "8h" # exp = now + jwtlifetime
errorTemplate = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/streaming-server/templates/error.gohtml" # error message for memoHandler
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment