Skip to content

Commit 0b75cfb

Browse files
Add https pam-config and only log to syslog
1 parent 5560546 commit 0b75cfb

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

config.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ package humcommon
33
import (
44
"os"
55

6+
"github.com/sirupsen/logrus"
67
"gopkg.in/yaml.v2"
78
)
89

910
const defaultConfigFilePath = "/etc/https-user-management/config.yaml"
1011
const defaultTokenFilePath = "/etc/https-user-management/user.token"
1112

13+
var AppConfig *Config
14+
var ConfigError bool
15+
1216
type Config struct {
1317
TLS struct {
1418
CA string
@@ -42,9 +46,6 @@ func NewConfig(configPath string) (*Config, error) {
4246
return config, nil
4347
}
4448

45-
var AppConfig *Config
46-
var ConfigError bool
47-
4849
func init() {
4950
var err error
5051

@@ -68,6 +69,10 @@ func init() {
6869

6970
logger.Infof("AppConfig: %+v", *AppConfig)
7071

72+
if AppConfig.Debug {
73+
logger.SetLevel(logrus.DebugLevel)
74+
}
75+
7176
err = initTLS()
7277
if err != nil {
7378
ConfigError = true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Name: Enable HTTPS User Auth
2+
Default: yes
3+
Priority: 0
4+
Auth-Type: Primary
5+
Auth:
6+
[success=end default=ignore] pam_https.so nullok_secure try_first_pass
7+
Auth-Initial:
8+
[success=end default=ignore] pam_https.so nullok_secure

logger.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package humcommon
22

33
import (
4+
"io"
45
"log/syslog"
56

67
"github.com/sirupsen/logrus"
@@ -18,9 +19,11 @@ func initLogger() {
1819
logger = logrus.New()
1920
hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
2021
logger.SetReportCaller(true)
22+
logger.SetLevel(logrus.WarnLevel)
2123

2224
if err == nil {
2325
logger.Hooks.Add(hook)
26+
logger.SetOutput(io.Discard)
2427
}
2528
}
2629

0 commit comments

Comments
 (0)