-
Notifications
You must be signed in to change notification settings - Fork 408
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 to set custom REDIS keys for security endpoint and PSK ID #1398
Conversation
Hi, thx for this PR. 🙏 Before to talk about the legal agreement issue 👇 and review the code, could you explain why you need this ? maybe you can explain a little your use case and the context where you need it ? This should help to provide a solution for your need. |
Hi, For the moment I use a custom Wanted to avoid such a copy-pasting and to make life a bit easier when upgrading the gateway to the next milestone. Was not sure what is the correct way to do that, decided to create a PR. By the way, ECA is settled now. |
Looks useful, I'm starting to mix Leshan data structure and some other applications in the same Redis cluster, and I have the same need: a way to change the prefix to organize the data better. That said, I'm not sure this should still be static and set by a setter, but a final attribute you can set using a constructor. |
955498d
to
7f2aeab
Compare
@jvermillard thank you for suggestion, constructor is much better, indeed. |
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
7f2aeab
to
4ad7307
Compare
OK I understand.
👍
👍 |
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
Maybe out of scope of this PR, but I also feel that default redis key value are not so good... Being more consistent : 1) 2) What do you think ? Should we at least change Should we add more prefix to all key ? Do we need a Leshan global prefix used for all store ? e.g. : This allow to have separate namespaces at cost of more bytes. Don't know if we should go in that way 🤷 |
4ad7307
to
ffb14c0
Compare
Yes, we have a gateway in production environment based on a v2.0.0-M10. Trying to keep it up to date with the latest Leshan since v1.0.0-RC2. Didn't face any critical issues so far.
Not really, but I realize that for sake of consistency and convenience it might be nice to have an ability to customize REDIS keys or at least a root prefix. |
Good to know 🙂
I think this is better to limit this PR to Maybe we should also decide about #1398 (comment) before to move forward on RegistrationStore ? 🤔 |
Maybe if we need to discuss about RedisRegistrationStore we can use #1249. |
@sbernard31 if you write a migration script, I'm fine with the rename to EP#PSKID 😂 |
Yes, no issues so far. Migration was rather easy and straightforward. Regarding #1398 (comment):
As for me, I like the
Those who will experience issues with the new keys could easily override them to current ones and perform the migration later if needed.
Let's indeed continue the discussion in #1249 . |
Thx a lot for this feedback. 🙏 About
I'm waiting for your opinion about prefix. 🙂 |
c82d93e
to
dcaf66f
Compare
Updated the PR accordingly. Any suggestions on the wording in javadoc are welcome.
From my point of view, if you have a Redis instance dedicated for Leshan, prefix by store makes the most sense. Because it provides a necessary grouping and a quick overview of what is stored under those keys. Global prefix might be useful only when Redis is shared between services, but in this case the prefix |
dcaf66f
to
070aa87
Compare
I review the last commit and it looks good to me. 👍 Just a small detail about the changes on
It makes sense to me. So let's add only 1 store prefix. Remaining questions are :
If we want to provide a way to set prefix we need to decide how ? none exclusive solution could be : For prefix do you prefer to continue with this PR or a new one ? Again thx for your contribution, that's really appreciated 🙏 |
Sorry about that, probably a bad habit of mine from other projects. Will keep it in mind next time. I would go for I will update this PR with prefix setting.
Yes, right after finishing current PR. |
Not a big deal 😉
👍
I can confirm Leshan code base has several Builder. There are generally added when there is too many parameters in constructors or too many constructors.
I agree adding builder for I just said that to let you know the big picture.
If you chose constructor, this makes sense to me.
Great 👍 |
That was exactly what I thought about right after sending my previous comment 🙂
I totally agree with you and will add a builder then. |
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
ℹ️ Some tips :
If documentation or those automatic comments are not clear enough, please create a new issue to discus about how to enhance it. |
❌ Java Import are not sorted ! (more details) Ensure your code build locally using:
Or just validate java import with :
You can sort Java import with :
See also How configure your IDE. |
Thank you @sbernard31 , those are all valid points and suggestions. |
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/eclipse/leshan/integration/tests/util/RedisSecureIntegrationTestHelper.java
Outdated
Show resolved
Hide resolved
leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/LeshanServerDemo.java
Outdated
Show resolved
Hide resolved
leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/LeshanServerDemo.java
Outdated
Show resolved
Hide resolved
bab6ffb
to
fc8c4fc
Compare
Except : #1398 (comment), this looks good to me 👍 About |
leshan-server-redis/src/main/java/org/eclipse/leshan/server/redis/RedisSecurityStore.java
Outdated
Show resolved
Hide resolved
I didn't notice that your Builder is not fluent. securityStore = new RedisSecurityStore.Builder(jedis).
.setPrefix(null) //
.setEndpointByPskIdKey("EPKEY") //
.setSecurityInfoByEndpointPrefix("SECKey").build(); |
Don't know what I was thinking of, of course setters should return |
fc8c4fc
to
bd8b389
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ I think we're good now.
I play a bit with it and it seems to work, I also tested it locally with mvn clean install javadoc:javadoc -Predis
and all seems good 👍 !
I will now integrated this in master
.
Thank you very much for this contribution 🙏
(as I said we will ignore the github action issue, I haven't time to go deeper in it and didn't find any obvious way to fix it) |
Thank you for all your advice and for patience 👍 I will start #1249 now. |
You're welcome.
👍 |
Added setters for
SEC_EP
andPSKID_SEC
to be able to override the default values.