Unverified Commit cc95480f authored by synaptic-cleft's avatar synaptic-cleft Committed by GitHub
Browse files

Merge pull request #163 from privacybydesign/use-upstream-cobra

Use upstream cobra
parents 965762b9 c1a8d0f8
......@@ -20,7 +20,6 @@ require (
github.com/hashicorp/go-retryablehttp v0.6.2
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/jackc/pgx v3.6.2+incompatible
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jasonlvhit/gocron v0.0.0-20180312192515-54194c9749d4
github.com/jinzhu/gorm v1.9.12
github.com/lib/pq v1.3.0 // indirect
......@@ -32,15 +31,13 @@ require (
github.com/onsi/gomega v1.9.0 // indirect
github.com/privacybydesign/gabi v0.0.0-20210520084001-626ad7db13a6
github.com/shopspring/decimal v1.2.0 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/sietseringers/cobra v1.0.1-0.20200909200314-c50c3838234b
github.com/sietseringers/go-sse v0.0.0-20200801161811-e2cf2c63ca50
github.com/sietseringers/pflag v1.0.4-0.20200909193609-0cde7e893819
github.com/sietseringers/viper v1.3.2-0.20200909194413-4120aa4ee8e8
github.com/sirupsen/logrus v1.4.2
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/spf13/afero v1.2.0 // indirect
github.com/spf13/cast v1.3.0
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
github.com/timshannon/bolthold v0.0.0-20190812165541-a85bcc049a2e // indirect
github.com/x-cray/logrus-prefixed-formatter v0.5.2
......
......@@ -115,7 +115,7 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
......@@ -182,7 +182,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
......@@ -237,8 +236,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/privacybydesign/gabi v0.0.0-20210506134416-e693d79c02c8 h1:dyl0VhClxTShXg6a6IcG1a5J/4UvAYe+nki1j2cFSTw=
github.com/privacybydesign/gabi v0.0.0-20210506134416-e693d79c02c8/go.mod h1:HQ6L5rKBY7qaqcheK6zpaVf7fhGWD0PvUAXJTDws+0M=
github.com/privacybydesign/gabi v0.0.0-20210520084001-626ad7db13a6 h1:SHiL7fXMzKqLJJRWcsKxje1qwLym4iXL92KLps+duEY=
github.com/privacybydesign/gabi v0.0.0-20210520084001-626ad7db13a6/go.mod h1:HQ6L5rKBY7qaqcheK6zpaVf7fhGWD0PvUAXJTDws+0M=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
......@@ -258,14 +255,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sietseringers/cobra v1.0.1-0.20200909200314-c50c3838234b h1:JgxSvnphvOl8CzgVlqvsWj1IriJDn1IeW2RREgkf1VE=
github.com/sietseringers/cobra v1.0.1-0.20200909200314-c50c3838234b/go.mod h1:LBZ5PhFJJ2MifAViiJlh6eHpN9axaFIRmaphQtvJLi4=
github.com/sietseringers/go-sse v0.0.0-20200801161811-e2cf2c63ca50 h1:vgWWQM2SnMoO9BiUZ2WFAYuYF6U0jNss9Vn/PZoi+tU=
github.com/sietseringers/go-sse v0.0.0-20200801161811-e2cf2c63ca50/go.mod h1:W/QHK9G0i5yrmHvej5+hhoFMXTSZIWHGQRcpbGgqV9s=
github.com/sietseringers/pflag v1.0.4-0.20200909193609-0cde7e893819 h1:/pQ1w1jGvgHKK4GeD3BRyWMIRM+z/7U4sFlHMKZxc94=
github.com/sietseringers/pflag v1.0.4-0.20200909193609-0cde7e893819/go.mod h1:ShnscXtg5c8cfamt8PcDo9o/NslhdkEzOk4WCv0YQhU=
github.com/sietseringers/viper v1.3.2-0.20200909194413-4120aa4ee8e8 h1:5jmSN+BkH9aIhQ51wmQ4Xj0DigyjheRmaLhXvlKgd+I=
github.com/sietseringers/viper v1.3.2-0.20200909194413-4120aa4ee8e8/go.mod h1:bCZfZa1otE5Ly0unfZMHMOUfOMBwqU0EQJpdVPH8EzA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
......@@ -282,13 +273,15 @@ github.com/spf13/afero v1.2.0 h1:O9FblXGxoTc51M+cqr74Bm2Tmt4PvkA5iu/j8HrkNuY=
github.com/spf13/afero v1.2.0/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
......@@ -305,7 +298,6 @@ github.com/timshannon/bolthold v0.0.0-20180829183128-83840edea944/go.mod h1:jUig
github.com/timshannon/bolthold v0.0.0-20190812165541-a85bcc049a2e h1:FC5JjwU5y5ZBR/vH8LhmPman3k5dep45jRyCpR1VDVQ=
github.com/timshannon/bolthold v0.0.0-20190812165541-a85bcc049a2e/go.mod h1:jUigdmrbdCxcIDEFrq82t4X9805XZfwFZoYUap0ET/U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
......@@ -313,7 +305,6 @@ github.com/x448/float16 v0.8.3/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcY
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......@@ -365,7 +356,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
......@@ -441,7 +431,6 @@ google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBr
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
......@@ -450,16 +439,16 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.61.0 h1:LBCdW4FmFYL4s/vDZD1RQYX7oAR6IjujCYgMdbHBR10=
gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
......
......@@ -8,72 +8,73 @@ import (
"regexp"
"strings"
"github.com/go-errors/errors"
"github.com/mitchellh/mapstructure"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare"
"github.com/spf13/cast"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/go-errors/errors"
"github.com/mitchellh/mapstructure"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
func configureEmail() keyshare.EmailConfiguration {
// If username/password are specified for the email server, build an authentication object.
var emailAuth smtp.Auth
if viper.GetString("email-username") != "" {
if viper.GetString("email_username") != "" {
emailAuth = smtp.PlainAuth(
"",
viper.GetString("email-username"),
viper.GetString("email-password"),
viper.GetString("email-hostname"),
viper.GetString("email_username"),
viper.GetString("email_password"),
viper.GetString("email_hostname"),
)
}
return keyshare.EmailConfiguration{
EmailServer: viper.GetString("email-server"),
EmailServer: viper.GetString("email_server"),
EmailAuth: emailAuth,
EmailFrom: viper.GetString("email-from"),
DefaultLanguage: viper.GetString("default-language"),
EmailFrom: viper.GetString("email_from"),
DefaultLanguage: viper.GetString("default_language"),
}
}
func configureIRMAServer() *server.Configuration {
return &server.Configuration{
SchemesPath: viper.GetString("schemes-path"),
SchemesAssetsPath: viper.GetString("schemes-assets-path"),
SchemesUpdateInterval: viper.GetInt("schemes-update"),
DisableSchemesUpdate: viper.GetInt("schemes-update") == 0,
SchemesPath: viper.GetString("schemes_path"),
SchemesAssetsPath: viper.GetString("schemes_assets_path"),
SchemesUpdateInterval: viper.GetInt("schemes_update"),
DisableSchemesUpdate: viper.GetInt("schemes_update") == 0,
IssuerPrivateKeysPath: viper.GetString("privkeys"),
RevocationDBType: viper.GetString("revocation-db-type"),
RevocationDBConnStr: viper.GetString("revocation-db-str"),
RevocationDBType: viper.GetString("revocation_db_type"),
RevocationDBConnStr: viper.GetString("revocation_db_str"),
RevocationSettings: irma.RevocationSettings{},
URL: viper.GetString("url"),
DisableTLS: viper.GetBool("no-tls"),
DisableTLS: viper.GetBool("no_tls"),
Email: viper.GetString("email"),
EnableSSE: viper.GetBool("sse"),
Verbose: viper.GetInt("verbose"),
Quiet: viper.GetBool("quiet"),
LogJSON: viper.GetBool("log-json"),
LogJSON: viper.GetBool("log_json"),
Logger: logger,
Production: viper.GetBool("production"),
MaxSessionLifetime: viper.GetInt("max-session-lifetime"),
JwtIssuer: viper.GetString("jwt-issuer"),
JwtPrivateKey: viper.GetString("jwt-privkey"),
JwtPrivateKeyFile: viper.GetString("jwt-privkey-file"),
AllowUnsignedCallbacks: viper.GetBool("allow-unsigned-callbacks"),
AugmentClientReturnURL: viper.GetBool("augment-client-return-url"),
MaxSessionLifetime: viper.GetInt("max_session_lifetime"),
JwtIssuer: viper.GetString("jwt_issuer"),
JwtPrivateKey: viper.GetString("jwt_privkey"),
JwtPrivateKeyFile: viper.GetString("jwt_privkey_file"),
AllowUnsignedCallbacks: viper.GetBool("allow_unsigned_callbacks"),
AugmentClientReturnURL: viper.GetBool("augment_client_return_url"),
}
}
func configureTLS() *tls.Config {
conf, err := server.TLSConf(
viper.GetString("tls-cert"),
viper.GetString("tls-cert-file"),
viper.GetString("tls-privkey"),
viper.GetString("tls-privkey-file"))
viper.GetString("tls_cert"),
viper.GetString("tls_cert_file"),
viper.GetString("tls_privkey"),
viper.GetString("tls_privkey_file"))
if err != nil {
die("", err)
}
......@@ -83,11 +84,16 @@ func configureTLS() *tls.Config {
func readConfig(cmd *cobra.Command, name, logname string, configpaths []string, productionDefaults map[string]interface{}) {
dashReplacer := strings.NewReplacer("-", "_")
viper.SetEnvKeyReplacer(dashReplacer)
viper.SetFileKeyReplacer(dashReplacer)
viper.SetEnvPrefix(strings.ToUpper(name))
viper.AutomaticEnv()
if err := viper.BindPFlags(cmd.Flags()); err != nil {
// Bind cmd flags to viper, such that configuration files use underscores instead of dashes
f := cmd.Flags()
normalizeFunc := f.GetNormalizeFunc()
f.SetNormalizeFunc(func(fs *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(dashReplacer.Replace(string(normalizeFunc(fs, name))))
})
if err := viper.BindPFlags(f); err != nil {
die("", err)
}
......@@ -118,7 +124,7 @@ func readConfig(cmd *cobra.Command, name, logname string, configpaths []string,
err := viper.ReadInConfig() // Hold error checking until we know how much of it to log
// Create our logger instance
logger = server.NewLogger(viper.GetInt("verbose"), viper.GetBool("quiet"), viper.GetBool("log-json"))
logger = server.NewLogger(viper.GetInt("verbose"), viper.GetBool("quiet"), viper.GetBool("log_json"))
// First log output: hello, development or production mode, log level
mode := "development"
......@@ -165,7 +171,7 @@ func handleMapOrString(key string, dest interface{}) error {
func handlePermission(typ string) []string {
if !viper.IsSet(typ) {
if typ == "revoke-perms" || (viper.GetBool("production") && typ == "issue-perms") {
if typ == "revoke_perms" || (viper.GetBool("production") && typ == "issue_perms") {
return []string{}
} else {
return []string{"*"}
......
......@@ -6,7 +6,7 @@ import (
"github.com/go-errors/errors"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/common"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
var downloadCmd = &cobra.Command{
......
package cmd
import (
"regexp"
"strings"
)
// headerFlagsTemplate is copied from cobra.Command.UsageTemplate, modified to include an invocation
// of insertHeaders on the flags, which intersperses the flags with headers defined in the
// flagHeaders variable.
var headerFlagsTemplate = `Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces | insertHeaders .CommandPath}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`
var flagHeaders = map[string]map[string]string{}
func insertHeaders(cmdPath string, flags string) string {
headers := flagHeaders[cmdPath]
if len(headers) == 0 {
return flags
}
in := strings.Split(flags, "\n")
out := make([]string, 0, len(in)+len(headers))
r := regexp.MustCompile(`^\s+(-\w, )?--([^ ]*)`)
for _, line := range in {
matches := r.FindStringSubmatch(line)
header := headers[matches[2]]
if header != "" {
out = append(out, "\n"+header)
}
out = append(out, line)
}
return strings.Join(out, "\n")
}
......@@ -30,7 +30,7 @@ import (
"strconv"
"github.com/privacybydesign/gabi/gabikeys"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
"github.com/go-errors/errors"
)
......
......@@ -11,7 +11,7 @@ import (
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi/gabikeys"
"github.com/privacybydesign/irmago/internal/common"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
// issuerKeygenCmd represents the keygen command
......
......@@ -14,7 +14,7 @@ import (
"github.com/privacybydesign/gabi/gabikeys"
"github.com/privacybydesign/gabi/keyproof"
"github.com/privacybydesign/irmago/internal/common"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
var issuerKeyproveCmd = &cobra.Command{
......
......@@ -13,7 +13,7 @@ import (
"github.com/privacybydesign/gabi/gabikeys"
"github.com/privacybydesign/gabi/keyproof"
"github.com/privacybydesign/irmago/internal/common"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
var issuerKeyverifyCmd = &cobra.Command{
......
package cmd
import "github.com/sietseringers/cobra"
import "github.com/spf13/cobra"
// issuerCmd represents the issuer command
var issuerCmd = &cobra.Command{
......
......@@ -11,7 +11,7 @@ import (
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi/signed"
"github.com/privacybydesign/irmago/internal/common"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
// keygenCmd represents the keygen command
......
......@@ -5,7 +5,7 @@ import (
"io/ioutil"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/sietseringers/cobra"
"github.com/spf13/cobra"
)
var keyshareKeygenCmd = &cobra.Command{
......
......@@ -5,8 +5,8 @@ import (
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/myirmaserver"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var myirmaServerCmd = &cobra.Command{
......@@ -31,6 +31,10 @@ var myirmaServerCmd = &cobra.Command{
func init() {
keyshareRootCmd.AddCommand(myirmaServerCmd)
myirmaServerCmd.SetUsageTemplate(headerFlagsTemplate)
headers := map[string]string{}
flagHeaders["irma keyshare myirmaserver"] = headers
flags := myirmaServerCmd.Flags()
flags.SortFlags = false
......@@ -43,20 +47,21 @@ func init() {
flags.String("static-prefix", "/", "Host static files under this URL prefix")
flags.Bool("sse", false, "Enable server sent for status updates (experimental)")
headers["port"] = "Server address and port to listen on"
flags.IntP("port", "p", 8080, "port at which to listen")
flags.StringP("listen-addr", "l", "", "address at which to listen (default 0.0.0.0)")
flags.StringSlice("cors-allowed-origins", nil, "CORS allowed origins")
flags.Lookup("port").Header = `Server address and port to listen on`
headers["db-type"] = "Database configuration"
flags.String("db-type", string(myirmaserver.DBTypePostgres), "Type of database to connect keyshare server to")
flags.String("db", "", "Database server connection string")
flags.Lookup("db-type").Header = `Database configuration`
headers["keyshare-attributes"] = "IRMA session configuration"
flags.StringSlice("keyshare-attributes", nil, "Attributes allowed for login to myirma")
flags.StringSlice("email-attributes", nil, "Attributes allowed for adding email addresses")
flags.Int("session-lifetime", myirmaserver.SessionLifetimeDefault, "Session lifetime in seconds")
flags.Lookup("keyshare-attributes").Header = `IRMA session configuration`
headers["email-server"] = "Email configuration (leave empty to disable sending emails)"
flags.String("email-server", "", "Email server to use for sending email address confirmation emails")
flags.String("email-hostname", "", "Hostname used in email server tls certificate (leave empty when mail server does not use tls)")
flags.String("email-username", "", "Username to use when authenticating with email server")
......@@ -71,20 +76,19 @@ func init() {
flags.StringToString("delete-account-subjects", nil, "Translated subject lines for the delete account email")
flags.StringToString("delete-account-files", nil, "Translated emails for the delete account email")
flags.Int("delete-delay", 0, "delay in days before a user or email address deletion becomes effective")
flags.Lookup("email-server").Header = `Email configuration (leave empty to disable sending emails)`
headers["tls-cert"] = "TLS configuration (leave empty to disable TLS)"
flags.String("tls-cert", "", "TLS certificate (chain)")
flags.String("tls-cert-file", "", "path to TLS certificate (chain)")
flags.String("tls-privkey", "", "TLS private key")
flags.String("tls-privkey-file", "", "path to TLS private key")
flags.Bool("no-tls", false, "Disable TLS")
flags.Lookup("tls-cert").Header = `TLS configuration (leave empty to disable TLS)`
headers["verbose"] = "Other options"
flags.CountP("verbose", "v", "verbose (repeatable)")
flags.BoolP("quiet", "q", false, "quiet")
flags.Bool("log-json", false, "Log in JSON format")
flags.Bool("production", false, "Production mode")
flags.Lookup("verbose").Header = `Other options`
}
func configureMyirmaServer(cmd *cobra.Command) (*myirmaserver.Configuration, error) {
......@@ -95,24 +99,24 @@ func configureMyirmaServer(cmd *cobra.Command) (*myirmaserver.Configuration, err
Configuration: configureIRMAServer(),
EmailConfiguration: configureEmail(),
CORSAllowedOrigins: viper.GetStringSlice("cors-allowed-origins"),
CORSAllowedOrigins: viper.GetStringSlice("cors_allowed_origins"),
StaticPath: viper.GetString("static-path"),
StaticPrefix: viper.GetString("static-prefix"),
StaticPath: viper.GetString("static_path"),
StaticPrefix: viper.GetString("static_prefix"),
DBType: myirmaserver.DBType(viper.GetString("db-type")),
DBConnStr: viper.GetString("db-str"),
DBType: myirmaserver.DBType(viper.GetString("db_type")),
DBConnStr: viper.GetString("db_str"),
LoginEmailSubjects: viper.GetStringMapString("login-email-subjects"),
LoginEmailFiles: viper.GetStringMapString("login-email-files"),
LoginEmailBaseURL: viper.GetStringMapString("login-url"),
DeleteEmailFiles: viper.GetStringMapString("delete-email-files"),
DeleteEmailSubjects: viper.GetStringMapString("delete-email-subjects"),
DeleteAccountFiles: viper.GetStringMapString("delete-account-files"),
DeleteAccountSubjects: viper.GetStringMapString("delete-account-subjects"),
DeleteDelay: viper.GetInt("delete-delay"),
LoginEmailSubjects: viper.GetStringMapString("login_email_subjects"),
LoginEmailFiles: viper.GetStringMapString("login_email_files"),
LoginEmailBaseURL: viper.GetStringMapString("login_url"),
DeleteEmailFiles: viper.GetStringMapString("delete_email_files"),
DeleteEmailSubjects: viper.GetStringMapString("delete_email_subjects"),
DeleteAccountFiles: viper.GetStringMapString("delete_account_files"),
DeleteAccountSubjects: viper.GetStringMapString("delete_account_subjects"),
DeleteDelay: viper.GetInt("delete_delay"),
SessionLifetime: viper.GetInt("session-lifetime"),
SessionLifetime: viper.GetInt("session_lifetime"),
}
if conf.Production && conf.DBType != myirmaserver.DBTypePostgres {
......@@ -121,12 +125,12 @@ func configureMyirmaServer(cmd *cobra.Command) (*myirmaserver.Configuration, err
conf.URL = server.ReplacePortString(viper.GetString("url"), viper.GetInt("port"))
for _, v := range viper.GetStringSlice("keyshare-attributes") {
for _, v := range viper.GetStringSlice("keyshare_attributes") {
conf.KeyshareAttributes = append(
conf.KeyshareAttributes,
irma.NewAttributeTypeIdentifier(v))
}
for _, v := range viper.GetStringSlice("email-attributes") {
for _, v := range viper.GetStringSlice("email_attributes") {
conf.EmailAttributes = append(
conf.EmailAttributes,
irma.NewAttributeTypeIdentifier(v))
......
......@@ -9,9 +9,9 @@ import (
"syscall"
"github.com/privacybydesign/irmago/server"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var keyshareRootCmd = &cobra.Command{
......@@ -30,7 +30,7 @@ type stoppableServer interface {
func runServer(serv stoppableServer, logger *logrus.Logger) {
// Determine full listening address.
fullAddr := fmt.Sprintf("%s:%d", viper.GetString("listen-addr"), viper.GetInt("port"))
fullAddr := fmt.Sprintf("%s:%d", viper.GetString("listen_addr"), viper.GetInt("port"))
// Load TLS configuration
TLSConfig := configureTLS()
......
......@@ -6,8 +6,8 @@ import (
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/keyshareserver"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var keyshareServerCmd = &cobra.Command{
......@@ -32,6 +32,10 @@ var keyshareServerCmd = &cobra.Command{
func init() {
keyshareRootCmd.AddCommand(keyshareServerCmd)
keyshareServerCmd.SetUsageTemplate(headerFlagsTemplate)
headers := map[string]string{}
flagHeaders["irma keyshare server"] = headers
flags := keyshareServerCmd.Flags()
flags.SortFlags = false
flags.StringP("config", "c", "", "path to configuration file")
......@@ -41,14 +45,15 @@ func init() {
flags.StringP("privkeys", "k", "", "path to IRMA private keys")
flags.StringP("url", "u", "", "external URL to server to which the IRMA client connects, \":port\" being replaced by --port value")
headers["port"] = "Server address and port to listen on"
flags.IntP("port", "p", 8080, "port at which to listen")
flags.StringP("listen-addr", "l", "", "address at which to listen (default 0.0.0.0)")
flags.Lookup("port").Header = `Server address and port to listen on`
headers["db-type"] = "Database configuration"
flags.String("db-type", string(keyshareserver.DBTypePostgres), "Type of database to connect keyshare server to")
flags.String("db", "", "Database server connection string")
flags.Lookup("db-type").Header = `Database configuration`
headers["jwt-privkey"] = "Cryptographic keys"
flags.String("jwt-privkey", "", "Private jwt key of keyshare server")
flags.String("jwt-privkey-file", "", "Path to file containing private jwt key of keyshare server")
flags.Int("jwt-privkey-id", 0, "Key identifier of keyshare server public key matching used private key")
......@@ -56,11 +61,11 @@ func init() {