Skip to content

Access remote artifacts in private repository using secrets #164

@lbroudoux

Description

@lbroudoux

Reason/Context

As of today, it is not possible to access remote artifacts living in a private repository protected with a Secret.

The base microcks-testcontainers-java library allows this to be done easily because it provides withSecret() and withMainRemoteArtifacts() methods that can be used programmatically by the user. The logic of DevServices being different with everything done for you from a set of properties.

Description

We need to define additional properties to enable the definition of secrets and their attachment to remote artifacts.

Implementation ideas

I propose a new set of properties that enable the DevService to create secrets on startup for you. It could be something like:

# For a secret named 'my-secret'. We don't need an additional description.
quarkus.microcks.devservices.secrets.my-secret.type=basic                        // Secret of basic type 
quarkus.microcks.devservices.secrets.my-secret.username=my-username              // Basic secret needs a username and password
quarkus.microcks.devservices.secrets.my-secret.password=env:REPOSITORY_PASSWORD  // Password will be extracted from env variable

# For a secret named 'my-token'. We don't need an additional description.
quarkus.microcks.devservices.secrets.my-token.type=token                    // Secret of token type 
quarkus.microcks.devservices.secrets.my-token.token=env:REPOSITORY_TOKEN    // Token secret needs a token that will be extracted from env variable
quarkus.microcks.devservices.secrets.my-token.token-header=x-my-token       // Optional: if token is not using the standard 'Authorization: Bearer <token>' header form

Now, we also need to configure the association between the remote artifact and the secret to use when downloading it. I propose using an optional suffix just after the URL to specify the secret name to use.

As of today, we have this way to define remote artifacts with a comma-separated list:

quarkus.microcks.devservices.remote-artifacts.primaries=https://raw.githubusercontent.com/microcks/microcks/master/samples/films.graphql,https://myprivaterepo.com/samples/openapi.yaml

As the RF3986 defines the unreserved characters as follow:

unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

and the unreserved characters being:

reserved    = gen-delims / sub-delims
gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="

we need to use other characters to split the URL from the secret name.

Thus, I propose using an optional "pipe" delimiter with the secret name. Our above properties definition would then become:

quarkus.microcks.devservices.remote-artifacts.primaries=https://raw.githubusercontent.com/microcks/microcks/master/samples/films.graphql,https://myprivaterepo.com/samples/openapi.yaml|my-secret,<other_remote_artifact_url>

Thus, we'd be able to know that 1st remote artifact is publicly accessible, 2nd one is private, and Microcks must use the my-secret secret, 3rd is public (or private we actually don't know 😉 ).

What do you think of this proposition? Does it make sense? Do you see some other - more easy - solution?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions