Skip to content

Pass auth token to validate external#61

Merged
aqdas0307 merged 2 commits intomainfrom
feature/pass-user-auth-token
Feb 5, 2026
Merged

Pass auth token to validate external#61
aqdas0307 merged 2 commits intomainfrom
feature/pass-user-auth-token

Conversation

@aqdas0307
Copy link
Contributor

@aqdas0307 aqdas0307 commented Jan 30, 2026

What

User auth token now being passed to validate external

ONSdigital/dp-api-clients-go#455 <- user auth token passed here

Upgrade go to 1.24.12

How to review

Sense check
Confirm everything is okay/in place

Who can review

not me

@aqdas0307 aqdas0307 requested a review from a team as a code owner January 30, 2026 13:37
@aqdas0307 aqdas0307 force-pushed the feature/pass-user-auth-token branch 2 times, most recently from cb549c8 to e1e510c Compare February 2, 2026 16:49
Copy link
Contributor

@lindenmckenzie lindenmckenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor bits - I will think about the passing of the auth token.

api/jobs.go Outdated
ctx := r.Context()

userAuthToken, err := api.GetUserAuthToken(r)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No whitespace after error catch.

api/jobs.go Outdated
Comment on lines +130 to +132
log.Info(ctx, "no authorization header in request", log.Data{
"error": err.Error(),
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think you actually need to log the error here - it's a legitimate request and being dealt with successfully.

api/jobs.go Outdated
bearerToken := r.Header.Get(dprequest.AuthHeaderKey)
if bearerToken == "" {
return "", errors.New("authorization header missing")
// Get JTW token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get JTW token
// Get JWT token

api/jobs.go Outdated
Comment on lines +316 to +325
// GetUserAuthToken gets the user auth token from the Authorization header
func (api *MigrationAPI) GetUserAuthToken(r *http.Request) (string, error) {
authToken := r.Header.Get(dprequest.AuthHeaderKey)
if authToken == "" {
return "", errors.New("authorisation failed: no authorisation header in request")
}
authToken = strings.TrimPrefix(authToken, dprequest.BearerPrefix)

return authToken, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this needs to be part of the MigrationAPI struct.

I'm surprised it's not part of dp-net.

@@ -1,2 +1,2 @@
---
toolchain: go1.24.11
toolchain: go1.24.12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have a build file we don't need this file any more.

@aqdas0307 aqdas0307 force-pushed the feature/pass-user-auth-token branch 2 times, most recently from 26fa123 to 3131aa6 Compare February 4, 2026 10:11
@aqdas0307 aqdas0307 force-pushed the feature/pass-user-auth-token branch from 3131aa6 to c3167a3 Compare February 4, 2026 15:30
@aqdas0307 aqdas0307 merged commit c3167a3 into main Feb 5, 2026
11 checks passed
@aqdas0307 aqdas0307 deleted the feature/pass-user-auth-token branch February 5, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants