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

Native support for JWT #817

Open
rdelaage opened this issue Feb 20, 2025 · 3 comments
Open

Native support for JWT #817

rdelaage opened this issue Feb 20, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@rdelaage
Copy link

What are you building with SQLPage ?

A proof of concept for use as a general purpose engine for declarative apps

What is your problem ? A description of the problem, not the solution you are proposing.

I would like to manage sessions for users with a stateless solution

What are you currently doing ? Since your solution is not implemented in SQLPage currently, what are you doing instead ?

JWT or PHP sessions

Describe the solution you'd like

Provide two built-in functions (like in this project https://github.com/michelp/pgjwt):

  • sqlpage_jwt_sign(payload: json_str, secret: str) -> str provides a JWT signed using the provided secret
  • sqlpage_jwt_verify(jwt_token: str, secret: str) -> |header: json_str|payload: json_str|valid: bool| verifies that the provided JWT and gives the payload and the header

Describe alternatives you've considered

Using https://github.com/michelp/pgjwt

Additional context

@rdelaage rdelaage added the enhancement New feature or request label Feb 20, 2025
@lovasoa
Copy link
Collaborator

lovasoa commented Feb 23, 2025

Hello, and thank you for getting in touch ! This sounds very interesting ! Could you open a pull request ?

@rdelaage
Copy link
Author

Hello, I'm glad you find this interesting. I would be pleased to open a pull request. I have never programmed in Rust but if you give me some time I could try to draft something.
Could you give me some pointers of which parts of the program to modify to add functions?

@lovasoa
Copy link
Collaborator

lovasoa commented Feb 24, 2025

Sure !
We have a contribution guide here :
Don't hesitate to ping me if anything sounds unclear or too complex, I'll be happy to help !

For this particular issue, I think what you will be the most interested in is: https://github.com/sqlpage/SQLPage/blob/main/examples/official-site/functions.sql. You can declare new sqlpage functions entirely from that file.

For manipulating the jwt themselves, you can add https://crates.io/crates/jwt-simple to the dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants