mirror of
https://github.com/goauthentik/authentik
synced 2026-04-27 09:57:31 +02:00
* packages/client-go: init Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove mod/sum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix translate Signed-off-by: Jens Langhammer <jens@goauthentik.io> * no go replace Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update rust makefile with pwd Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix build Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't need a version ig? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude go client from cspell Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix main docker build Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
89 lines
4.7 KiB
Go
89 lines
4.7 KiB
Go
package application
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"goauthentik.io/internal/config"
|
|
api "goauthentik.io/packages/client-go"
|
|
)
|
|
|
|
func TestEndpointDefault(t *testing.T) {
|
|
pc := api.ProxyOutpostConfig{
|
|
OidcConfiguration: api.OpenIDConnectConfiguration{
|
|
AuthorizationEndpoint: "https://test.goauthentik.io/application/o/authorize/",
|
|
EndSessionEndpoint: "https://test.goauthentik.io/application/o/test-app/end-session/",
|
|
IntrospectionEndpoint: "https://test.goauthentik.io/application/o/introspect/",
|
|
Issuer: "https://test.goauthentik.io/application/o/test-app/",
|
|
JwksUri: "https://test.goauthentik.io/application/o/test-app/jwks/",
|
|
TokenEndpoint: "https://test.goauthentik.io/application/o/token/",
|
|
},
|
|
}
|
|
|
|
ep := GetOIDCEndpoint(pc, "https://authentik-host.test.goauthentik.io", false)
|
|
// Standard outpost, non embedded
|
|
// All URLs should use the host that they get from the config
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/authorize/", ep.AuthURL)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/token/", ep.TokenURL)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/test-app/", ep.Issuer)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/test-app/jwks/", ep.JwksUri)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/test-app/end-session/", ep.EndSessionEndpoint)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/introspect/", ep.TokenIntrospection)
|
|
}
|
|
|
|
func TestEndpointAuthentikHostBrowser(t *testing.T) {
|
|
c := config.Get()
|
|
c.AuthentikHostBrowser = "https://browser.test.goauthentik.io"
|
|
defer func() {
|
|
c.AuthentikHostBrowser = ""
|
|
}()
|
|
pc := api.ProxyOutpostConfig{
|
|
OidcConfiguration: api.OpenIDConnectConfiguration{
|
|
AuthorizationEndpoint: "https://test.goauthentik.io/application/o/authorize/",
|
|
EndSessionEndpoint: "https://test.goauthentik.io/application/o/test-app/end-session/",
|
|
IntrospectionEndpoint: "https://test.goauthentik.io/application/o/introspect/",
|
|
Issuer: "https://test.goauthentik.io/application/o/test-app/",
|
|
JwksUri: "https://test.goauthentik.io/application/o/test-app/jwks/",
|
|
TokenEndpoint: "https://test.goauthentik.io/application/o/token/",
|
|
UserinfoEndpoint: "https://test.goauthentik.io/application/o/userinfo/",
|
|
},
|
|
}
|
|
|
|
ep := GetOIDCEndpoint(pc, "https://authentik-host.test.goauthentik.io", false)
|
|
// Standard outpost, with AUTHENTIK_HOST_BROWSER set
|
|
// Only the authorize/end session URLs should be changed
|
|
assert.Equal(t, "https://browser.test.goauthentik.io/application/o/authorize/", ep.AuthURL)
|
|
assert.Equal(t, "https://browser.test.goauthentik.io/application/o/test-app/end-session/", ep.EndSessionEndpoint)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/token/", ep.TokenURL)
|
|
assert.Equal(t, "https://browser.test.goauthentik.io/application/o/test-app/", ep.Issuer)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/test-app/jwks/", ep.JwksUri)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/introspect/", ep.TokenIntrospection)
|
|
}
|
|
|
|
func TestEndpointEmbedded(t *testing.T) {
|
|
pc := api.ProxyOutpostConfig{
|
|
OidcConfiguration: api.OpenIDConnectConfiguration{
|
|
AuthorizationEndpoint: "https://test.goauthentik.io/application/o/authorize/",
|
|
EndSessionEndpoint: "https://test.goauthentik.io/application/o/test-app/end-session/",
|
|
IntrospectionEndpoint: "https://test.goauthentik.io/application/o/introspect/",
|
|
Issuer: "https://test.goauthentik.io/application/o/test-app/",
|
|
JwksUri: "https://test.goauthentik.io/application/o/test-app/jwks/",
|
|
TokenEndpoint: "https://test.goauthentik.io/application/o/token/",
|
|
UserinfoEndpoint: "https://test.goauthentik.io/application/o/userinfo/",
|
|
},
|
|
}
|
|
|
|
ep := GetOIDCEndpoint(pc, "https://authentik-host.test.goauthentik.io", true)
|
|
// Embedded outpost
|
|
// Browser URLs should use the config of "authentik_host", everything else can use what's
|
|
// received from the API endpoint
|
|
// Token URL is an exception since it's sent via a special HTTP transport that overrides the
|
|
// HTTP Host header, to make sure it's the same value as the issuer
|
|
assert.Equal(t, "https://authentik-host.test.goauthentik.io/application/o/authorize/", ep.AuthURL)
|
|
assert.Equal(t, "https://authentik-host.test.goauthentik.io/application/o/test-app/", ep.Issuer)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/token/", ep.TokenURL)
|
|
assert.Equal(t, "https://authentik-host.test.goauthentik.io/application/o/test-app/jwks/", ep.JwksUri)
|
|
assert.Equal(t, "https://authentik-host.test.goauthentik.io/application/o/test-app/end-session/", ep.EndSessionEndpoint)
|
|
assert.Equal(t, "https://test.goauthentik.io/application/o/introspect/", ep.TokenIntrospection)
|
|
}
|