mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
b4e570358e
* build: include major in go.mod module directive * fix: xflags * revert: cobra changes * fix: mock doc
38 lines
831 B
Go
38 lines
831 B
Go
package duo
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
duoapi "github.com/duosecurity/duo_api_golang"
|
|
|
|
"github.com/authelia/authelia/v4/internal/middlewares"
|
|
)
|
|
|
|
// NewDuoAPI create duo API instance.
|
|
func NewDuoAPI(duoAPI *duoapi.DuoApi) *APIImpl {
|
|
api := new(APIImpl)
|
|
api.DuoApi = duoAPI
|
|
|
|
return api
|
|
}
|
|
|
|
// Call call to the DuoAPI.
|
|
func (d *APIImpl) Call(values url.Values, ctx *middlewares.AutheliaCtx) (*Response, error) {
|
|
var response Response
|
|
|
|
_, responseBytes, err := d.DuoApi.SignedCall("POST", "/auth/v2/auth", values)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
ctx.Logger.Tracef("Duo Push Auth Response Raw Data for %s from IP %s: %s", ctx.GetSession().Username, ctx.RemoteIP().String(), string(responseBytes))
|
|
|
|
err = json.Unmarshal(responseBytes, &response)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &response, nil
|
|
}
|