-
Notifications
You must be signed in to change notification settings - Fork 8
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
Opening from S3 with credentials only via official mechanisms #160
Comments
If somehow possible it would be quite helpful to still support the direct credential entry. I am using this in a couple of projects, and it makes it much easier to explain this to collaborators, especially since the location of the credential file differs between operating system. If there's really no other way than I guess we can do without it, but maybe there is some way to add support for a credentials provider? |
I guess you could make MoBIE write to the aws credentials file. It will be a bit hacky (figure out the OS, and storage location), but why not having something like credential manager inside MoBIE that would take the project name (github URL) as ID and manage the keys (create new ones in the file if not yet existing). |
I asked chatGPT about it. It seems we could add a new What do you think?
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class SaveAWSCredentials {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter AWS Access Key ID: ");
String accessKeyId = scanner.nextLine();
System.out.println("Enter AWS Secret Access Key: ");
String secretAccessKey = scanner.nextLine();
String profileName = "default"; // Use "default" or another profile
name as needed
saveCredentials(accessKeyId, secretAccessKey, profileName);
}
private static void saveCredentials(String accessKeyId, String
secretAccessKey, String profileName) {
String homeDirectory = System.getProperty("user.home");
String awsCredentialsPath = homeDirectory + "/.aws/credentials"; //
For Linux and macOS
// For Windows, use: String awsCredentialsPath = homeDirectory +
"\\.aws\\credentials";
File credentialsFile = new File(awsCredentialsPath);
credentialsFile.getParentFile().mkdirs(); // Create the .aws
directory if it doesn't exist
try (FileWriter writer = new FileWriter(credentialsFile, true)) {
writer.append("\n[" + profileName + "]\n");
writer.append("aws_access_key_id = " + accessKeyId + "\n");
writer.append("aws_secret_access_key = " + secretAccessKey +
"\n");
System.out.println("Credentials saved successfully.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
In fact I am confused now, chatGPT says:
I am not sure what we are currently doing...do you? |
We are using this, but using generic users instead of creating an account per user. I.e. we usually have one user with read and one user with write access, and would distribute the credentials for the user with read access to whoever just needs to access the data.
This can be done, but it's not really a clean solution. I am not sure which library you're using now for reading n5/zarr, but not being able to pass on a credentials provider (or a client initialized with the credentials provider) seems to be a major lack of functionality. For reference, here is a simple example how to do this according to ChatGPT: |
We have to look whether we can use an n5 reader with credentials here:
|
OK, nice, in fact, upon closer examination the new n5 library provides functionality for this:
Is there something that I could easily test this with (you could send me the credentials in the EMBL chat)? |
In fact, ideal would be a real |
Yes, I think that's the best solution. It's probably best if you could get a bucket on the EMBL s3 for this. |
@martinschorb @constantinpape switching to the new N5 libraries I cannot easily support anymore that users would enter their S3 credentials into MoBIE, but they would follow the official AWS S3 mechanisms, which I think mean to store those credentials in some special file on their computer. Is that OK?
The text was updated successfully, but these errors were encountered: