Skip to content

Commit 0bc0388

Browse files
committed
/callback -> /token in backend
1 parent 4e4ee98 commit 0bc0388

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:22-slim AS frontend-builder
33

44
# Build arguments for frontend environment
55
ARG NUXT_PUBLIC_API_URL
6-
ARG NUXT_PUBLIC_CALLBACK_URL
6+
ARG NUXT_PUBLIC_TOKEN_URL
77
ARG NUXT_PUBLIC_LOGIN_URL
88
ARG NUXT_PUBLIC_RUDDERSTACK_WRITE_KEY
99
ARG NUXT_PUBLIC_RUDDERSTACK_DATA_PLANE_URL

backend/cmd/server/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ func main() {
268268
}
269269
slog.Info("Profiling endpoints enabled at /debug/pprof")
270270

271-
// Authentication callback endpoint (no JWT middleware)
271+
// Authentication token endpoint (no JWT middleware)
272272
authHandler := &handlers.AuthHandler{
273273
DB: db,
274274
Cfg: cfg,
275275
JWKS: jwks,
276276
MembersClient: membersClient,
277277
RoleService: roleService,
278278
}
279-
router.GET("/callback", authHandler.Callback)
279+
router.GET("/token", authHandler.Callback)
280280

281281
// Webhook handler for external content events
282282
webhookHandler := &handlers.WebhookHandler{

cloudbuild.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ steps:
44
- build
55
- '--no-cache'
66
- '--build-arg=NUXT_PUBLIC_API_URL=${_NUXT_PUBLIC_API_URL}'
7-
- '--build-arg=NUXT_PUBLIC_CALLBACK_URL=${_NUXT_PUBLIC_CALLBACK_URL}'
7+
- '--build-arg=NUXT_PUBLIC_TOKEN_URL=${_NUXT_PUBLIC_TOKEN_URL}'
88
- '--build-arg=NUXT_PUBLIC_LOGIN_URL=${_NUXT_PUBLIC_LOGIN_URL}'
99
- '--build-arg=NUXT_PUBLIC_RUDDERSTACK_WRITE_KEY=${_NUXT_PUBLIC_RUDDERSTACK_WRITE_KEY}'
1010
- '--build-arg=NUXT_PUBLIC_RUDDERSTACK_DATA_PLANE_URL=${_NUXT_PUBLIC_RUDDERSTACK_DATA_PLANE_URL}'
@@ -51,7 +51,7 @@ substitutions:
5151
_SERVICE_NAME: wayfarer
5252
_DEPLOY_REGION: europe-west3
5353
_NUXT_PUBLIC_API_URL: ''
54-
_NUXT_PUBLIC_CALLBACK_URL: ''
54+
_NUXT_PUBLIC_TOKEN_URL: ''
5555
_NUXT_PUBLIC_LOGIN_URL: ''
5656
_NUXT_PUBLIC_RUDDERSTACK_WRITE_KEY: ''
5757
_NUXT_PUBLIC_RUDDERSTACK_DATA_PLANE_URL: ''

frontend/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NUXT_PUBLIC_API_URL=
2-
NUXT_PUBLIC_CALLBACK_URL=
2+
NUXT_PUBLIC_TOKEN_URL=
33
NUXT_PUBLIC_LOGIN_URL=
44

55
# Analytics

frontend/app/pages/callback.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ onMounted(async () => {
2929
3030
try {
3131
const response = await $fetch<{ token: string }>(
32-
`${config.public.callbackUrl}?token=${token}`,
32+
`${config.public.tokenUrl}?token=${token}`,
3333
{ method: 'GET' },
3434
)
3535

frontend/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default defineNuxtConfig({
6060
runtimeConfig: {
6161
public: {
6262
apiUrl: 'http://localhost:8080/graphql',
63-
callbackUrl: 'http://localhost:8080/callback',
63+
tokenUrl: 'http://localhost:8080/token',
6464
loginUrl: 'https://app.bcc.media/r/sigve-test',
6565
rudderstackWriteKey: '',
6666
rudderstackDataPlaneUrl: '',

frontend/test/unit/AUTH_TESTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ We've created a comprehensive set of mock utilities for testing auth functionali
285285
- **`mockCreateError()`** - Mock Nuxt error creation
286286
- **`mockWindowLocation(pathname)`** - Mock window.location
287287
- **`mockUseRoute(query)`** - Mock Nuxt route with query parameters
288-
- **`mockUseRuntimeConfig()`** - Mock Nuxt runtime config (apiUrl, callbackUrl, loginUrl)
288+
- **`mockUseRuntimeConfig()`** - Mock Nuxt runtime config (apiUrl, tokenUrl, loginUrl)
289289
- **`mockFetch()`** - Mock $fetch for backend API calls
290290
- **`createMockFetchResponse(data, ok, status)`** - Mock fetch responses
291291

frontend/test/unit/auth.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ describe('Authentication Flow', () => {
518518

519519
describe('Callback Page', () => {
520520
describe('Token Validation', () => {
521-
const CALLBACK_URL = 'http://localhost:8080/callback'
521+
const TOKEN_URL = 'http://localhost:8080/token'
522522

523523
it('should validate token with backend on mount', async () => {
524524
const inputToken = 'incoming-token-from-oauth'
@@ -538,7 +538,7 @@ describe('Authentication Flow', () => {
538538
const { token } = route.query
539539
if (token) {
540540
const response = await fetch(
541-
`${config.public.callbackUrl}?token=${token}`,
541+
`${config.public.tokenUrl}?token=${token}`,
542542
{ method: 'GET' },
543543
)
544544
if (response && response.token) {
@@ -548,7 +548,7 @@ describe('Authentication Flow', () => {
548548
}
549549

550550
expect(fetch).toHaveBeenCalledWith(
551-
`${CALLBACK_URL}?token=${inputToken}`,
551+
`${TOKEN_URL}?token=${inputToken}`,
552552
{ method: 'GET' },
553553
)
554554
expect(setAccessToken).toHaveBeenCalledWith(validatedToken)
@@ -570,7 +570,7 @@ describe('Authentication Flow', () => {
570570
const config = mockUseRuntimeConfig()
571571

572572
const response = await fetch(
573-
`${config.public.callbackUrl}?token=${inputToken}`,
573+
`${config.public.tokenUrl}?token=${inputToken}`,
574574
)
575575
if (response && response.token) {
576576
setAccessToken(response.token)
@@ -593,7 +593,7 @@ describe('Authentication Flow', () => {
593593
const config = mockUseRuntimeConfig()
594594

595595
const response = await fetch(
596-
`${config.public.callbackUrl}?token=${inputToken}`,
596+
`${config.public.tokenUrl}?token=${inputToken}`,
597597
)
598598
if (response && response.token) {
599599
setAccessToken(response.token)
@@ -621,7 +621,7 @@ describe('Authentication Flow', () => {
621621
const config = mockUseRuntimeConfig()
622622

623623
const response = await fetch(
624-
`${config.public.callbackUrl}?token=${inputToken}`,
624+
`${config.public.tokenUrl}?token=${inputToken}`,
625625
)
626626
if (response && response.token) {
627627
setAccessToken(response.token)
@@ -672,7 +672,7 @@ describe('Authentication Flow', () => {
672672

673673
try {
674674
const response = await fetch(
675-
`${config.public.callbackUrl}?token=${invalidToken}`,
675+
`${config.public.tokenUrl}?token=${invalidToken}`,
676676
)
677677
if (response && response.token) {
678678
setAccessToken(response.token)
@@ -703,7 +703,7 @@ describe('Authentication Flow', () => {
703703

704704
try {
705705
const response = await fetch(
706-
`${config.public.callbackUrl}?token=${expiredToken}`,
706+
`${config.public.tokenUrl}?token=${expiredToken}`,
707707
)
708708
if (response && response.token) {
709709
setAccessToken(response.token)
@@ -735,7 +735,7 @@ describe('Authentication Flow', () => {
735735

736736
try {
737737
const response = await fetch(
738-
`${config.public.callbackUrl}?token=${inputToken}`,
738+
`${config.public.tokenUrl}?token=${inputToken}`,
739739
)
740740
if (response && response.token) {
741741
setAccessToken(response.token)
@@ -768,7 +768,7 @@ describe('Authentication Flow', () => {
768768

769769
try {
770770
const response = await fetch(
771-
`${config.public.callbackUrl}?token=${inputToken}`,
771+
`${config.public.tokenUrl}?token=${inputToken}`,
772772
)
773773
if (response && response.token) {
774774
setAccessToken(response.token)
@@ -796,7 +796,7 @@ describe('Authentication Flow', () => {
796796
const config = mockUseRuntimeConfig()
797797

798798
const response = await fetch(
799-
`${config.public.callbackUrl}?token=${inputToken}`,
799+
`${config.public.tokenUrl}?token=${inputToken}`,
800800
)
801801
if (response && response.token) {
802802
setAccessToken(response.token)
@@ -826,7 +826,7 @@ describe('Authentication Flow', () => {
826826
const config = mockUseRuntimeConfig()
827827

828828
const response = await fetch(
829-
`${config.public.callbackUrl}?token=${inputToken}`,
829+
`${config.public.tokenUrl}?token=${inputToken}`,
830830
)
831831
if (response && response.token) {
832832
setAccessToken(response.token)
@@ -860,7 +860,7 @@ describe('Authentication Flow', () => {
860860
const config = mockUseRuntimeConfig()
861861

862862
const response = await fetch(
863-
`${config.public.callbackUrl}?token=${inputToken}`,
863+
`${config.public.tokenUrl}?token=${inputToken}`,
864864
)
865865
if (response && response.token) {
866866
setAccessToken(response.token)
@@ -894,7 +894,7 @@ describe('Authentication Flow', () => {
894894
const config = mockUseRuntimeConfig()
895895

896896
const response = await fetch(
897-
`${config.public.callbackUrl}?token=${inputToken}`,
897+
`${config.public.tokenUrl}?token=${inputToken}`,
898898
)
899899
if (response && response.token) {
900900
setAccessToken(response.token)
@@ -924,7 +924,7 @@ describe('Authentication Flow', () => {
924924
const config = mockUseRuntimeConfig()
925925

926926
try {
927-
await fetch(`${config.public.callbackUrl}?token=${inputToken}`)
927+
await fetch(`${config.public.tokenUrl}?token=${inputToken}`)
928928
} catch (error) {
929929
console.error('Token validation failed:', error)
930930
}
@@ -948,7 +948,7 @@ describe('Authentication Flow', () => {
948948
const config = mockUseRuntimeConfig()
949949

950950
try {
951-
await fetch(`${config.public.callbackUrl}?token=${inputToken}`)
951+
await fetch(`${config.public.tokenUrl}?token=${inputToken}`)
952952
} catch (error) {
953953
errorState.value =
954954
error instanceof Error ? error.message : 'Unknown error'
@@ -972,7 +972,7 @@ describe('Authentication Flow', () => {
972972

973973
try {
974974
const response = await fetch(
975-
`${config.public.callbackUrl}?token=${inputToken}`,
975+
`${config.public.tokenUrl}?token=${inputToken}`,
976976
)
977977
if (response && response.token) {
978978
setAccessToken(response.token)
@@ -1003,7 +1003,7 @@ describe('Authentication Flow', () => {
10031003
// First attempt - fails
10041004
try {
10051005
const response = await fetch(
1006-
`${config.public.callbackUrl}?token=${inputToken}`,
1006+
`${config.public.tokenUrl}?token=${inputToken}`,
10071007
)
10081008
if (response && response.token) {
10091009
setAccessToken(response.token)
@@ -1016,7 +1016,7 @@ describe('Authentication Flow', () => {
10161016

10171017
// Retry - succeeds
10181018
const response = await fetch(
1019-
`${config.public.callbackUrl}?token=${inputToken}`,
1019+
`${config.public.tokenUrl}?token=${inputToken}`,
10201020
)
10211021
if (response && response.token) {
10221022
setAccessToken(response.token)
@@ -1851,7 +1851,7 @@ describe('Authentication Flow', () => {
18511851
// Step 4: Token validated with backend
18521852
fetch.mockResolvedValue({ token: validatedToken })
18531853
const response = await fetch(
1854-
`${config.public.callbackUrl}?token=${oauthToken}`,
1854+
`${config.public.tokenUrl}?token=${oauthToken}`,
18551855
)
18561856

18571857
// Step 5: Stored in cookie
@@ -2110,7 +2110,7 @@ describe('Authentication Flow', () => {
21102110
const config = mockUseRuntimeConfig()
21112111

21122112
const response = await fetch(
2113-
`${config.public.callbackUrl}?token=${tamperedToken}`,
2113+
`${config.public.tokenUrl}?token=${tamperedToken}`,
21142114
)
21152115

21162116
// Tampered token should be rejected by backend

frontend/test/utils/auth-mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export function mockUseRuntimeConfig() {
293293
return {
294294
public: {
295295
apiUrl: 'http://localhost:8080/graphql',
296-
callbackUrl: 'http://localhost:8080/callback',
296+
tokenUrl: 'http://localhost:8080/token',
297297
loginUrl: 'https://login.example.com/auth',
298298
},
299299
}

0 commit comments

Comments
 (0)