2016-09-26 18:48:55 +00:00
|
|
|
package service
|
2016-09-15 14:52:17 +00:00
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2016-09-15 14:52:17 +00:00
|
|
|
"time"
|
|
|
|
|
2017-06-22 19:50:45 +00:00
|
|
|
"github.com/kolide/fleet/server/kolide"
|
2016-09-15 14:52:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (mw loggingMiddleware) Login(ctx context.Context, username, password string) (user *kolide.User, token string, err error) {
|
|
|
|
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
_ = mw.logger.Log(
|
|
|
|
"method", "Login",
|
|
|
|
"user", username,
|
|
|
|
"err", err,
|
|
|
|
"took", time.Since(begin),
|
|
|
|
)
|
|
|
|
}(time.Now())
|
|
|
|
|
|
|
|
user, token, err = mw.Service.Login(ctx, username, password)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mw loggingMiddleware) Logout(ctx context.Context) (err error) {
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
_ = mw.logger.Log(
|
|
|
|
"method", "Logout",
|
|
|
|
"err", err,
|
|
|
|
"took", time.Since(begin),
|
|
|
|
)
|
|
|
|
}(time.Now())
|
|
|
|
|
|
|
|
err = mw.Service.Logout(ctx)
|
|
|
|
return
|
|
|
|
}
|
2017-05-09 00:43:48 +00:00
|
|
|
|
|
|
|
func (mw loggingMiddleware) InitiateSSO(ctx context.Context, relayURL string) (idpURL string, err error) {
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
_ = mw.logger.Log(
|
|
|
|
"method", "InitiateSSO",
|
|
|
|
"err", err,
|
|
|
|
"took", time.Since(begin),
|
|
|
|
)
|
|
|
|
}(time.Now())
|
|
|
|
|
|
|
|
idpURL, err = mw.Service.InitiateSSO(ctx, relayURL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mw loggingMiddleware) CallbackSSO(ctx context.Context, auth kolide.Auth) (sess *kolide.SSOSession, err error) {
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
_ = mw.logger.Log(
|
|
|
|
"method", "CallbackSSO",
|
|
|
|
"err", err,
|
|
|
|
"took", time.Since(begin),
|
|
|
|
)
|
|
|
|
}(time.Now())
|
|
|
|
sess, err = mw.Service.CallbackSSO(ctx, auth)
|
|
|
|
return
|
|
|
|
}
|
2017-05-17 15:58:40 +00:00
|
|
|
|
|
|
|
func (mw loggingMiddleware) SSOSettings(ctx context.Context) (settings *kolide.SSOSettings, err error) {
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
_ = mw.logger.Log(
|
|
|
|
"method", "SSOSettings",
|
|
|
|
"err", err,
|
|
|
|
"took", time.Since(begin),
|
|
|
|
)
|
|
|
|
}(time.Now())
|
|
|
|
settings, err = mw.Service.SSOSettings(ctx)
|
|
|
|
return
|
|
|
|
}
|