|
21 | 21 |
|
22 | 22 | profiles.auth = {
|
23 | 23 | enable = true;
|
| 24 | + domain = "authentik.localho.st"; |
24 | 25 | };
|
| 26 | + |
| 27 | + profiles.ingress.enable = true; |
| 28 | + |
25 | 29 | services.authentik.environmentFile = builtins.toFile "authentik-env-file" ''
|
26 | 30 | AUTHENTIK_SECRET_KEY=qwerty123456
|
27 | 31 | AUTHENTIK_BOOTSTRAP_PASSWORD=password
|
28 | 32 | AUTHENTIK_BOOTSTRAP_TOKEN=token
|
29 | 33 | '';
|
| 34 | + |
30 | 35 | services.authentik.blueprints = [{
|
31 | 36 | metadata.name = "grafana-oauth";
|
32 | 37 | entries = [
|
|
53 | 58 | sub_mode = "hashed_user_id";
|
54 | 59 | include_claims_in_id_token = true;
|
55 | 60 | issuer_mode = "per_provider";
|
56 |
| - redirect_uris = "http://localhost:3000/login/generic_oauth"; |
| 61 | + redirect_uris = "http://grafana.localho.st/login/generic_oauth"; |
57 | 62 | };
|
58 | 63 | }
|
59 | 64 | {
|
|
71 | 76 | }];
|
72 | 77 | profiles.monitoring = {
|
73 | 78 | enable = true;
|
74 |
| - domain = "localhost"; |
| 79 | + domain = "grafana.localho.st"; |
| 80 | + root_url = "%(protocol)s://%(domain)s/"; |
75 | 81 | oauth = {
|
76 | 82 | name = "Authentik";
|
77 | 83 | client_id_file = builtins.toFile "grafana-client-id" "grafana";
|
78 | 84 | client_secret_file = builtins.toFile "grafana-client-secret" "secret";
|
79 |
| - auth_url = "http://127.0.0.1:9000/application/o/authorize/"; |
80 |
| - token_url = "http://127.0.0.1:9000/application/o/token/"; |
81 |
| - api_url = "http://127.0.0.1:9000/application/o/userinfo/"; |
| 85 | + auth_url = "http://authentik.localho.st/application/o/authorize/"; |
| 86 | + token_url = "http://authentik.localho.st/application/o/token/"; |
| 87 | + api_url = "http://authentik.localho.st/application/o/userinfo/"; |
82 | 88 | };
|
83 | 89 | };
|
84 | 90 | };
|
85 | 91 |
|
86 | 92 | extraPythonPackages = p: [ p.playwright ];
|
87 | 93 |
|
88 | 94 | testScript = ''
|
| 95 | + import os |
| 96 | + from playwright.sync_api import sync_playwright, expect |
| 97 | +
|
89 | 98 | start_all()
|
90 | 99 |
|
| 100 | + machine.forward_port(80, 80) |
| 101 | +
|
91 | 102 | with subtest("Wait for authentik services to start"):
|
92 | 103 | machine.wait_for_unit("postgresql.service")
|
93 | 104 | machine.wait_for_unit("redis-authentik.service")
|
94 | 105 | machine.wait_for_unit("authentik-migrate.service")
|
95 | 106 | machine.wait_for_unit("authentik-worker.service")
|
96 | 107 | machine.wait_for_unit("authentik.service")
|
| 108 | + machine.wait_for_unit("nginx.service") |
97 | 109 |
|
98 | 110 | with subtest("Wait for Authentik itself to initialize"):
|
99 | 111 | machine.wait_for_open_port(9000)
|
100 |
| - machine.wait_until_succeeds("curl -fL http://localhost:9000/if/flow/initial-setup/ >&2") |
| 112 | + machine.wait_until_succeeds("curl -fL http://authentik.localho.st/if/flow/initial-setup/ >&2") |
101 | 113 |
|
102 | 114 | with subtest("Wait for Authentik blueprints to be applied"):
|
103 |
| - machine.wait_until_succeeds("curl -f http://localhost:9000/application/o/grafana/.well-known/openid-configuration >&2") |
104 |
| -
|
105 |
| - machine.forward_port(3000, 3000) |
106 |
| - machine.forward_port(9000, 9000) |
107 |
| -
|
108 |
| - from playwright.sync_api import sync_playwright, expect |
| 115 | + machine.wait_until_succeeds("curl -f http://authentik.localho.st/application/o/grafana/.well-known/openid-configuration >&2") |
109 | 116 |
|
110 | 117 | with sync_playwright() as p:
|
111 |
| - browser = p.chromium.launch() |
| 118 | + browser = p.chromium.launch(headless=os.environ.get("HEADLESS", "true") != "false") |
112 | 119 | page = browser.new_page()
|
113 | 120 |
|
114 | 121 | with subtest("Login page"):
|
115 |
| - page.goto("http://localhost:3000/login") |
| 122 | + page.goto("http://grafana.localho.st/login") |
116 | 123 | page.reload()
|
117 | 124 | page.get_by_role("link", name="Sign in with Authentik").click()
|
118 | 125 | with subtest("Enter username"):
|
|
0 commit comments