Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /auth/token endpoint for service to exchange secret for api token #656

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

willeasp
Copy link

@willeasp willeasp commented Mar 6, 2025

Fix client missing client authentication

  • Add /auth/token endpoint for services, users still use /auth/github to retrieve tokens
  • Introduce a secret (stored as ENV variable API_SECRET currently)
  • introduce bot: boolean field in User entity

Closes #653

Copy link
Contributor

@moritzzingg-netlight moritzzingg-netlight left a comment

Choose a reason for hiding this comment

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

Create work, just small things which I thing should be adjusted.


if (newToken !== undefined) {
reply.headers['x-auth-token'] = newToken
} else {
request.log.error('No user found')
request.log.error('Could not create new token for user', user)
Copy link
Contributor

Choose a reason for hiding this comment

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

newToken can have the value undefined if the current token is still valid for longer than 15min, in that case it is not necessary to provide a new token. So catching the case that the token is undefined as an error is wrong here.

Copy link
Author

Choose a reason for hiding this comment

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

aaaaah good catch

}
}
)
app.post(
Copy link
Contributor

Choose a reason for hiding this comment

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

Great work🚀


interface Userinfo {
interface GithubUserinfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not happy with this name as the user info acts both for github users and non-github clients, so keeping the more general name userinfo might be better, also that one is not perfect. But, to fully fix this we would have to separate real users and clients.

})

const token = (await response.json()).token
console.log(token)
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed before merge

@Klimatbyran Klimatbyran deleted a comment from willeasp Mar 7, 2025
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.

[Bug] Missing Client Authentication as a result of the new User Authentication
2 participants