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

Allow for creation of tokens without exp #1007

Merged
merged 1 commit into from
Jun 12, 2022
Merged

Allow for creation of tokens without exp #1007

merged 1 commit into from
Jun 12, 2022

Conversation

pluk77
Copy link
Contributor

@pluk77 pluk77 commented Apr 20, 2022

Allow exp=0 to be set in the payload during creation, which will create a token without an EXP. Related to #676 and #889.

@pluk77 pluk77 changed the title Update LcobucciJWSProvider.php Allow for creation of tokens without exp Apr 21, 2022
@pluk77
Copy link
Contributor Author

pluk77 commented May 19, 2022

Hello @chalasr . Any idea yet when you will have some time to review and consider this PR?

@chalasr
Copy link
Collaborator

chalasr commented May 23, 2022

Can we use--ttl=0 to skip adding the exp claim instead? And remove the payload option? I'm not sure we need it. At least it deserves its own discussion.

@pluk77
Copy link
Contributor Author

pluk77 commented May 24, 2022

I can sure try and make it work with --ttl=0. As for the payload, to us it is important as we use the payload to encapsulate additional meta-data. Our system can not do without, but I can remove it and make my own command that includes this specific feature. I will separate the two features into separate PRs so you can decide.

@pluk77
Copy link
Contributor Author

pluk77 commented May 25, 2022

I have removed the payload option from this patch. I still believe it is a good addition. We use a generated JWT token as an access token between two applications that reside on the same infrastructure. The token never leaves our network nor does it go to the user. But because we need a bit more context in the token, we add that via the payload. When we generate the token programmatically, we can add the payload without problems. Now I need a solution for the payload to be added by tokens generated from the command-line.

I have created a second PR, but now with the additional payload option for your consideration. If you choose not to allow the additional payload, I can always create my own command to implement this, but I would really like this PR to be considered for next release.

->addOption('user-class', 'c', InputOption::VALUE_REQUIRED)
->setDescription('Generates a JWT token with optional payload')
->addArgument('username', InputArgument::REQUIRED, 'Username of user to be retreived from user provider')
->addArgument('ttl', InputArgument::OPTIONAL, 'Ttl in seconds to be added to current time. If not provided, the ttl configured in the bundle will be used. Use 0 to generate token without exp', null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about making it an option instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no objection to that. Will amend accordingly.

@chalasr
Copy link
Collaborator

chalasr commented Jun 12, 2022

Thank you @pluk77.

@chalasr chalasr merged commit 698cea5 into lexik:2.x Jun 12, 2022
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