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

✨ feat(VSecM): 448 Java SDK #732

Merged
merged 4 commits into from
May 7, 2024
Merged

Conversation

sahinakyol
Copy link
Contributor

448 Java SDK

Description

Created Java SDK poc

Changes

List the major changes you have made in bullet points:

  • sdk-java
  • app/safe/internal/server/handle/handle.go
  • core/validation/validation.go

Test Policy Compliance

  • [-] I have added or updated unit tests for my changes.
  • [-] I have included integration tests where applicable.
  • All new and existing tests pass successfully.

Code Quality

  • I have followed the coding standards for this project.
  • I have performed a self-review of my code.
  • [-] My code is well-commented, particularly in areas that may be difficult
    to understand.

Documentation

  • [-] I have made corresponding changes to the documentation (if applicable).
  • [-] I have updated any relevant READMEs or wiki pages.

Additional Comments

Include any additional comments or context about the PR here.

Checklist

Before you submit this PR, please make sure:

  • You have read the contributing guidelines and
    especially the test policy.
  • You have thoroughly tested your changes.
  • You have followed all the contributing guidelines for this project.
  • You understand and agree that your contributions will be publicly available
    under the project's license.

By submitting this pull request, you confirm that my contribution is made under
the terms of the project's license and that you have the authority to grant
these rights.


Thank you for your contribution to VMware Secrets Manager
🐢⚡️!

Create Java SDK poc

Signed-off-by: sahinakyol <akyolsahinn@gmail.com>
@@ -18,7 +18,7 @@ import (
// IsSentinel returns true if the given SPIFFEID is a Sentinel ID.
// It does this by checking if the SPIFFEID has the SpiffeIdPrefixForSentinel as its prefix.
func IsSentinel(spiffeid string) bool {
return strings.HasPrefix(spiffeid, env.SpiffeIdPrefixForSentinel())
return strings.HasPrefix(spiffeid, env.SpiffeIdPrefixForSentinel()) || strings.HasPrefix(spiffeid, "spiffe://vsecm.com/workload/sdk-java/ns/vsecm-system/sa/sdk-java/n/")
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a dangerous hack.

Any SDK request shall not identify itself as Sentinel.

SDK can only read secrets, and that’s the job of a workload.

Comment on lines 67 to 79
apiVersion: v1
kind: Secret
metadata:
# The string after `vsecm-secret-` must match the workload's name.
# For example, this is an VSecM-managed secret for the workload named `example`
# with the SPIFFE ID
# `"spiffe://vsecm.com/workload/example\
# /ns/{{ .PodMeta.Namespace }}\
# /sa/{{ .PodSpec.ServiceAccountName }}\
# /n/{{ .PodMeta.Name }}"`
name: sdk-java
namespace: vsecm-system
type: Opaque
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn’t need this secret.

org.opencontainers.image.description="Java SDK for VMware Secrets Manager" \
org.opencontainers.image.version=$APP_VERSION \
org.opencontainers.image.authors="VSecM Maintainers <maintainers@vsecm.com>" \
org.opencontainers.image.vendor="VMware, Inc." \
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no such vendor as VMware, Inc. anymore :)

Comment on lines 11 to 14
startServer();
WatchService watchService = WatchService.getInstance();
TaskFactory taskFactory = new FetchSecretsTaskFactory();
watchService.scheduleTask(taskFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am assuming these are just to test the functionality, and the main() function will not be a part of the SDK. — we are providing a library; not an executable.

We’ll have two functions:

  • Watch()
  • Fetch()

We don’t need a health check server.

--

This will not be a Pod; it will be a library where others can build their own pods.

import java.util.logging.Level;
import java.util.logging.Logger;

public class WsecmHttpClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it’s VSecM, not Wsecm


private void run() {
try {
fetchService.fetch();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fetch() shall return an object.

We need signature parity with the Go SDK.

@v0lkan
Copy link
Contributor

v0lkan commented Mar 21, 2024

I think it’s a good start; I need to build and run it to see how it behaves.

I’ll share my thoughts with @sahinakyol and @BulldromeQ separately, probably over Slack.

And probably early next week :D

I am very very swamped right now.

But thanks a lot for the hard work.

I appreciate that 🙏 .

@v0lkan
Copy link
Contributor

v0lkan commented Mar 24, 2024

Folks; I’ll check this out; but not likely this weekend :(.
cc: @sahinakyol @BulldromeQ

I’m trying to cut a new release, close some issues etc.

Signed-off-by: sahinakyol <akyolsahinn@gmail.com>
Signed-off-by: sahinakyol <akyolsahinn@gmail.com>
@v0lkan
Copy link
Contributor

v0lkan commented May 5, 2024

@sahinakyol if you can revert your changes that are outside sdk-java folder; I can merge this one.

We can iterate on it later anyway.

Signed-off-by: sahinakyol <akyolsahinn@gmail.com>
Copy link
Contributor

@v0lkan v0lkan left a comment

Choose a reason for hiding this comment

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

Looking good.

We (I) can test it later down the line, and we can proceed from there.

Thanks for your contribution @sahinakyol 🙏 .

@v0lkan v0lkan merged commit 564db67 into vmware-tanzu:main May 7, 2024
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