api: migrate to openapi generator v6 (#2968)

* migrate to openapi generator v6

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* bump api

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens L 2022-05-26 15:15:30 +02:00 committed by GitHub
parent 4b6c1da51d
commit a286f999e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 32 additions and 30 deletions

View File

@ -65,7 +65,7 @@ gen-client-web:
docker run \ docker run \
--rm -v ${PWD}:/local \ --rm -v ${PWD}:/local \
--user ${UID}:${GID} \ --user ${UID}:${GID} \
openapitools/openapi-generator-cli:v6.0.0-beta generate \ openapitools/openapi-generator-cli:v6.0.0 generate \
-i /local/schema.yml \ -i /local/schema.yml \
-g typescript-fetch \ -g typescript-fetch \
-o /local/gen-ts-api \ -o /local/gen-ts-api \
@ -83,7 +83,7 @@ gen-client-go:
docker run \ docker run \
--rm -v ${PWD}:/local \ --rm -v ${PWD}:/local \
--user ${UID}:${GID} \ --user ${UID}:${GID} \
openapitools/openapi-generator-cli:v5.2.1 generate \ openapitools/openapi-generator-cli:v6.0.0 generate \
-i /local/schema.yml \ -i /local/schema.yml \
-g go \ -g go \
-o /local/gen-go-api \ -o /local/gen-go-api \

View File

@ -124,7 +124,7 @@ func attemptProxyStart(ws *web.WebServer, u *url.URL) {
ws.ProxyServer = srv ws.ProxyServer = srv
ac.Server = srv ac.Server = srv
l.Debug("attempting to start outpost") l.Debug("attempting to start outpost")
err := ac.StartBackgorundTasks() err := ac.StartBackgroundTasks()
if err != nil { if err != nil {
l.WithError(err).Warning("outpost failed to start") l.WithError(err).Warning("outpost failed to start")
attempt += 1 attempt += 1

2
go.mod
View File

@ -26,7 +26,7 @@ require (
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.1 github.com/stretchr/testify v1.7.1
goauthentik.io/api/v3 v3.2022052.5 goauthentik.io/api/v3 v3.2022052.6
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/boj/redistore.v1 v1.0.0-20160128113310-fc113767cd6b gopkg.in/boj/redistore.v1 v1.0.0-20160128113310-fc113767cd6b

2
go.sum
View File

@ -360,6 +360,8 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
goauthentik.io/api/v3 v3.2022052.5 h1:kaW52rZZE+wUsp47Ab9OBaLCPNGbqQkCrQWkrbzy14Q= goauthentik.io/api/v3 v3.2022052.5 h1:kaW52rZZE+wUsp47Ab9OBaLCPNGbqQkCrQWkrbzy14Q=
goauthentik.io/api/v3 v3.2022052.5/go.mod h1:QM9J32HgYE4gL71lWAfAoXSPdSmLVLW08itfLI3Mo10= goauthentik.io/api/v3 v3.2022052.5/go.mod h1:QM9J32HgYE4gL71lWAfAoXSPdSmLVLW08itfLI3Mo10=
goauthentik.io/api/v3 v3.2022052.6 h1:NF9WLbWWcqOViPhYbJoUUdILnXtOYJrjFmHHqL513wY=
goauthentik.io/api/v3 v3.2022052.6/go.mod h1:QM9J32HgYE4gL71lWAfAoXSPdSmLVLW08itfLI3Mo10=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=

View File

@ -27,7 +27,7 @@ const ConfigLogLevel = "log_level"
type APIController struct { type APIController struct {
Client *api.APIClient Client *api.APIClient
Outpost api.Outpost Outpost api.Outpost
GlobalConfig api.Config GlobalConfig *api.Config
Server Outpost Server Outpost
@ -113,7 +113,7 @@ func (a *APIController) Start() error {
if err != nil { if err != nil {
return err return err
} }
err = a.StartBackgorundTasks() err = a.StartBackgroundTasks()
if err != nil { if err != nil {
return err return err
} }
@ -165,7 +165,7 @@ func (a *APIController) OnRefresh() error {
return err return err
} }
func (a *APIController) StartBackgorundTasks() error { func (a *APIController) StartBackgroundTasks() error {
OutpostInfo.With(prometheus.Labels{ OutpostInfo.With(prometheus.Labels{
"outpost_name": a.Outpost.Name, "outpost_name": a.Outpost.Name,
"outpost_type": a.Server.Type(), "outpost_type": a.Server.Type(),

View File

@ -15,7 +15,7 @@ import (
var initialSetup = false var initialSetup = false
func doGlobalSetup(outpost api.Outpost, globalConfig api.Config) { func doGlobalSetup(outpost api.Outpost, globalConfig *api.Config) {
l := log.WithField("logger", "authentik.outpost") l := log.WithField("logger", "authentik.outpost")
m := outpost.Managed.Get() m := outpost.Managed.Get()
level, ok := outpost.Config[ConfigLogLevel] level, ok := outpost.Config[ConfigLogLevel]

View File

@ -50,7 +50,7 @@ func MockAK(outpost api.Outpost, globalConfig api.Config) *APIController {
ac := &APIController{ ac := &APIController{
Client: apiClient, Client: apiClient,
GlobalConfig: globalConfig, GlobalConfig: &globalConfig,
token: token, token: token,
logger: log, logger: log,

View File

@ -149,7 +149,7 @@ func (ds *DirectSearcher) Search(req *search.Request) (ldap.ServerSearchResult,
return fmt.Errorf("failed to get userinfo") return fmt.Errorf("failed to get userinfo")
} }
flags.UserInfo = &u flags.UserInfo = u
} }
u := make([]api.User, 1) u := make([]api.User, 1)

View File

@ -16,7 +16,7 @@ func (ms *MemorySearcher) FetchUsers() []api.User {
return nil, err return nil, err
} }
ms.log.WithField("page", page).WithField("count", len(users.Results)).Debug("fetched users") ms.log.WithField("page", page).WithField("count", len(users.Results)).Debug("fetched users")
return &users, nil return users, nil
} }
page := 1 page := 1
users := make([]api.User, 0) users := make([]api.User, 0)
@ -43,7 +43,7 @@ func (ms *MemorySearcher) FetchGroups() []api.Group {
return nil, err return nil, err
} }
ms.log.WithField("page", page).WithField("count", len(groups.Results)).Debug("fetched groups") ms.log.WithField("page", page).WithField("count", len(groups.Results)).Debug("fetched groups")
return &groups, nil return groups, nil
} }
page := 1 page := 1
groups := make([]api.Group, 0) groups := make([]api.Group, 0)

View File

@ -141,7 +141,7 @@ func (ms *MemorySearcher) Search(req *search.Request) (ldap.ServerSearchResult,
if flags.UserPk == u.Pk { if flags.UserPk == u.Pk {
//TODO: Is there a better way to clone this object? //TODO: Is there a better way to clone this object?
fg := api.NewGroup(g.Pk, g.NumPk, g.Name, g.Parent, g.ParentName, []int32{flags.UserPk}, []api.GroupMember{u}) fg := api.NewGroup(g.Pk, g.NumPk, g.Name, g.Parent, g.ParentName, []int32{flags.UserPk}, []api.GroupMember{u})
fg.SetAttributes(*g.Attributes) fg.SetAttributes(g.Attributes)
fg.SetIsSuperuser(*g.IsSuperuser) fg.SetIsSuperuser(*g.IsSuperuser)
groups = append(groups, group.FromAPIGroup(*fg, ms.si)) groups = append(groups, group.FromAPIGroup(*fg, ms.si))
break break

View File

@ -149,7 +149,7 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
mux.HandleFunc("/outpost.goauthentik.io/sign_in", a.handleRedirect) mux.HandleFunc("/outpost.goauthentik.io/sign_in", a.handleRedirect)
mux.HandleFunc("/outpost.goauthentik.io/callback", a.handleCallback) mux.HandleFunc("/outpost.goauthentik.io/callback", a.handleCallback)
mux.HandleFunc("/outpost.goauthentik.io/sign_out", a.handleSignOut) mux.HandleFunc("/outpost.goauthentik.io/sign_out", a.handleSignOut)
switch *p.Mode { switch *p.Mode.Get() {
case api.PROXYMODE_PROXY: case api.PROXYMODE_PROXY:
err = a.configureProxy() err = a.configureProxy()
case api.PROXYMODE_FORWARD_SINGLE: case api.PROXYMODE_FORWARD_SINGLE:
@ -186,7 +186,7 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
} }
func (a *Application) Mode() api.ProxyMode { func (a *Application) Mode() api.ProxyMode {
return *a.proxyConfig.Mode return *a.proxyConfig.Mode.Get()
} }
func (a *Application) ProxyConfig() api.ProxyOutpostConfig { func (a *Application) ProxyConfig() api.ProxyOutpostConfig {

View File

@ -107,7 +107,7 @@ func (a *Application) ReportMisconfiguration(r *http.Request, msg string, fields
Action: api.EVENTACTIONS_CONFIGURATION_ERROR, Action: api.EVENTACTIONS_CONFIGURATION_ERROR,
App: "authentik.providers.proxy", // must match python apps.py name App: "authentik.providers.proxy", // must match python apps.py name
ClientIp: *api.NewNullableString(api.PtrString(r.RemoteAddr)), ClientIp: *api.NewNullableString(api.PtrString(r.RemoteAddr)),
Context: &fields, Context: fields,
} }
_, _, err := a.ak.Client.EventsApi.EventsEventsCreate(context.Background()).EventRequest(req).Execute() _, _, err := a.ak.Client.EventsApi.EventsEventsCreate(context.Background()).EventRequest(req).Execute()
if err != nil { if err != nil {

View File

@ -19,7 +19,7 @@ func urlMustParse(u string) *url.URL {
func TestIsAllowlisted_Proxy_Single(t *testing.T) { func TestIsAllowlisted_Proxy_Single(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_PROXY.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_PROXY.Ptr())
assert.Equal(t, false, a.IsAllowlisted(urlMustParse(""))) assert.Equal(t, false, a.IsAllowlisted(urlMustParse("")))
a.UnauthenticatedRegex = []*regexp.Regexp{ a.UnauthenticatedRegex = []*regexp.Regexp{
@ -30,7 +30,7 @@ func TestIsAllowlisted_Proxy_Single(t *testing.T) {
func TestIsAllowlisted_Proxy_Domain(t *testing.T) { func TestIsAllowlisted_Proxy_Domain(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
assert.Equal(t, false, a.IsAllowlisted(urlMustParse(""))) assert.Equal(t, false, a.IsAllowlisted(urlMustParse("")))
a.UnauthenticatedRegex = []*regexp.Regexp{ a.UnauthenticatedRegex = []*regexp.Regexp{

View File

@ -56,9 +56,9 @@ func (a *Application) forwardHandleTraefik(rw http.ResponseWriter, r *http.Reque
host := "" host := ""
s, _ := a.sessions.Get(r, constants.SessionName) s, _ := a.sessions.Get(r, constants.SessionName)
// Optional suffix, which is appended to the URL // Optional suffix, which is appended to the URL
if *a.proxyConfig.Mode == api.PROXYMODE_FORWARD_SINGLE { if *a.proxyConfig.Mode.Get() == api.PROXYMODE_FORWARD_SINGLE {
host = web.GetHost(r) host = web.GetHost(r)
} else if *a.proxyConfig.Mode == api.PROXYMODE_FORWARD_DOMAIN { } else if *a.proxyConfig.Mode.Get() == api.PROXYMODE_FORWARD_DOMAIN {
eh, err := url.Parse(a.proxyConfig.ExternalHost) eh, err := url.Parse(a.proxyConfig.ExternalHost)
if err != nil { if err != nil {
a.log.WithField("host", a.proxyConfig.ExternalHost).WithError(err).Warning("invalid external_host") a.log.WithField("host", a.proxyConfig.ExternalHost).WithError(err).Warning("invalid external_host")

View File

@ -106,7 +106,7 @@ func TestForwardHandleNginx_Single_Claims(t *testing.T) {
func TestForwardHandleNginx_Domain_Blank(t *testing.T) { func TestForwardHandleNginx_Domain_Blank(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.CookieDomain = api.PtrString("foo") a.proxyConfig.CookieDomain = api.PtrString("foo")
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/nginx", nil) req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/nginx", nil)
@ -118,7 +118,7 @@ func TestForwardHandleNginx_Domain_Blank(t *testing.T) {
func TestForwardHandleNginx_Domain_Header(t *testing.T) { func TestForwardHandleNginx_Domain_Header(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.CookieDomain = api.PtrString("foo") a.proxyConfig.CookieDomain = api.PtrString("foo")
a.proxyConfig.ExternalHost = "http://auth.test.goauthentik.io" a.proxyConfig.ExternalHost = "http://auth.test.goauthentik.io"
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/nginx", nil) req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/nginx", nil)

View File

@ -100,7 +100,7 @@ func TestForwardHandleTraefik_Single_Claims(t *testing.T) {
func TestForwardHandleTraefik_Domain_Blank(t *testing.T) { func TestForwardHandleTraefik_Domain_Blank(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.CookieDomain = api.PtrString("foo") a.proxyConfig.CookieDomain = api.PtrString("foo")
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/traefik", nil) req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/traefik", nil)
@ -112,7 +112,7 @@ func TestForwardHandleTraefik_Domain_Blank(t *testing.T) {
func TestForwardHandleTraefik_Domain_Header(t *testing.T) { func TestForwardHandleTraefik_Domain_Header(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.CookieDomain = api.PtrString("foo") a.proxyConfig.CookieDomain = api.PtrString("foo")
a.proxyConfig.ExternalHost = "http://auth.test.goauthentik.io" a.proxyConfig.ExternalHost = "http://auth.test.goauthentik.io"
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/traefik", nil) req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/traefik", nil)

View File

@ -34,7 +34,7 @@ func TestCheckRedirectParam(t *testing.T) {
func TestCheckRedirectParam_Domain(t *testing.T) { func TestCheckRedirectParam_Domain(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.CookieDomain = api.PtrString("t.goauthentik.io") a.proxyConfig.CookieDomain = api.PtrString("t.goauthentik.io")
req, _ := http.NewRequest("GET", "https://a.t.goauthentik.io/outpost.goauthentik.io/auth/start", nil) req, _ := http.NewRequest("GET", "https://a.t.goauthentik.io/outpost.goauthentik.io/auth/start", nil)

View File

@ -17,7 +17,7 @@ func newTestApplication() *Application {
CookieSecret: api.PtrString(ak.TestSecret()), CookieSecret: api.PtrString(ak.TestSecret()),
ExternalHost: "https://ext.t.goauthentik.io", ExternalHost: "https://ext.t.goauthentik.io",
CookieDomain: api.PtrString(""), CookieDomain: api.PtrString(""),
Mode: api.PROXYMODE_FORWARD_SINGLE.Ptr(), Mode: *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_SINGLE.Ptr()),
SkipPathRegex: api.PtrString("/skip.*"), SkipPathRegex: api.PtrString("/skip.*"),
BasicAuthEnabled: api.PtrBool(true), BasicAuthEnabled: api.PtrBool(true),
BasicAuthUserAttribute: api.PtrString("username"), BasicAuthUserAttribute: api.PtrString("username"),

View File

@ -12,7 +12,7 @@ import (
func TestRedirectToStart_Proxy(t *testing.T) { func TestRedirectToStart_Proxy(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_PROXY.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_PROXY.Ptr())
a.proxyConfig.ExternalHost = "https://test.goauthentik.io" a.proxyConfig.ExternalHost = "https://test.goauthentik.io"
req, _ := http.NewRequest("GET", "/foo/bar/baz", nil) req, _ := http.NewRequest("GET", "/foo/bar/baz", nil)
@ -29,7 +29,7 @@ func TestRedirectToStart_Proxy(t *testing.T) {
func TestRedirectToStart_Forward(t *testing.T) { func TestRedirectToStart_Forward(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_SINGLE.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_SINGLE.Ptr())
a.proxyConfig.ExternalHost = "https://test.goauthentik.io" a.proxyConfig.ExternalHost = "https://test.goauthentik.io"
req, _ := http.NewRequest("GET", "/foo/bar/baz", nil) req, _ := http.NewRequest("GET", "/foo/bar/baz", nil)
@ -47,7 +47,7 @@ func TestRedirectToStart_Forward(t *testing.T) {
func TestRedirectToStart_Forward_Domain_Invalid(t *testing.T) { func TestRedirectToStart_Forward_Domain_Invalid(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.CookieDomain = api.PtrString("foo") a.proxyConfig.CookieDomain = api.PtrString("foo")
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.ExternalHost = "https://test.goauthentik.io" a.proxyConfig.ExternalHost = "https://test.goauthentik.io"
req, _ := http.NewRequest("GET", "/foo/bar/baz", nil) req, _ := http.NewRequest("GET", "/foo/bar/baz", nil)
@ -65,7 +65,7 @@ func TestRedirectToStart_Forward_Domain_Invalid(t *testing.T) {
func TestRedirectToStart_Forward_Domain(t *testing.T) { func TestRedirectToStart_Forward_Domain(t *testing.T) {
a := newTestApplication() a := newTestApplication()
a.proxyConfig.CookieDomain = api.PtrString("goauthentik.io") a.proxyConfig.CookieDomain = api.PtrString("goauthentik.io")
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr() a.proxyConfig.Mode = *api.NewNullableProxyMode(api.PROXYMODE_FORWARD_DOMAIN.Ptr())
a.proxyConfig.ExternalHost = "https://test.goauthentik.io" a.proxyConfig.ExternalHost = "https://test.goauthentik.io"
req, _ := http.NewRequest("GET", "/foo/bar/baz", nil) req, _ := http.NewRequest("GET", "/foo/bar/baz", nil)