Commit 8105378a authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch 'secret-controller-init' into 'develop'

Init secret controller

See merge request !1
parents 70569e4a 9dbb719b
Loading
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+36 −0
Original line number Diff line number Diff line
application-prod.properties
application-dev.properties

HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

.gitlab-ci.yml

0 → 100644
+40 −0
Original line number Diff line number Diff line
include:
  - project: osl/code/org.etsi.osl.main
    ref: main
    file: 
      - ci-templates/default.yml
      - ci-templates/build.yml
    rules:
      - if: '$CI_COMMIT_REF_NAME == "main"'
  
  - project: osl/code/org.etsi.osl.main
    ref: develop
    file: 
      - ci-templates/default.yml
      - ci-templates/build.yml
    rules:
      - if: '$CI_COMMIT_REF_NAME == "develop"'

  - project: osl/code/org.etsi.osl.main
    ref: $CI_COMMIT_REF_NAME
    file: 
      - ci-templates/default.yml
      - ci-templates/build.yml
    rules:
      - if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"'

  - project: osl/code/org.etsi.osl.main
    ref: develop
    file: 
      - ci-templates/default.yml
      - ci-templates/build_unprotected.yml
    rules:
      - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED == "false"'

maven_build:
  extends: .maven_build

docker_build:
  extends: .docker_build
  needs:
    - maven_build

Dockerfile

0 → 100644
+6 −0
Original line number Diff line number Diff line
FROM ibm-semeru-runtimes:open-17.0.7_7-jdk

RUN mkdir -p /opt/openslice/lib/

COPY target/secret-controller-0.1.0.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/secret-controller-0.1.0.jar"]
+71 −66
Original line number Diff line number Diff line
# org.etsi.osl.controllers.secrets
# Openslice secret controller

Generic controller for OpenSlice (ETSI OSL) that automatically stores secret
characteristics into Hashicorp Vault, an external secret management solution,
and replaces the original characteristic with a link to it.

## Configuration

## Getting started
The controller can be configured using the usual mechanisms provided by the
Spring framework, with the main options being the following:

To make it easy for you to get started with GitLab, here's a list of recommended next steps.
```yaml
spring:
  artemis:
    broker-url: "tcp://artemis:61616"
    user: artemis
    password: password

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!

## Add your files

* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:

vault:
  uri: "http://vault:8200"
  kvPath: "openslice"
  token: "hvs.AAAAAAAAAA"
```
cd existing_repo
git remote add origin https://labs.etsi.org/rep/osl/code/addons/org.etsi.osl.controllers.secrets.git
git branch -M main
git push -uf origin main
```

## Integrate with your tools

* [Set up project integrations](https://labs.etsi.org/rep/osl/code/addons/org.etsi.osl.controllers.secrets/-/settings/integrations)

## Collaborate with your team

* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)

## Test and Deploy

Use the built-in continuous integration in GitLab.
The `vault.uri` is the address of the Hashicorp Vault server to be used, the
`kvPath` is the path where the KV secrets engine for Openslice (explained in the
next section) was mounted, and `token` is the authentication token that allows
access to the KV secret store.

* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
## Vault setup

***
In order for the controller to function the Vault must be configured to have
a KV secret engine version 2 mounted. By default this is expected to reside at
`openslice`, but it can be changed in the controller configuration. To create
the KV engine the following command may be used:

# Editing this README

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
```sh
$ vault secrets enable -path openslice -version=2 -options=max_versions=1 kv
```

## Suggestions for a good README
Then a policy and token can be created for the controller using the following
commands:

Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
```sh
$ vault policy write openslice-policy - <<EOF
path "openslice/data/*" {
  capabilities = ["read", "create", "update", "patch", "delete"]
}
EOF
$ vault token create -policy="openslice-policy"
```

## Name
Choose a self-explaining name for your project.
The generated token should be set in the `vault.token` property of the
controller.

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Building

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
The controller can be built using the normal Maven workflows.

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
```sh
$ mvn package
```

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
To build the container, the controller must have been built first and then
a standard `docker build` can be used in the project's root.

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
```sh
$ docker build -t osl-secret-controller .
```

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Quickstart

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
A Docker compose file is available in the project's root to quickly bootstrap a
testing and development environment. This compose should not be used in production.

## Contributing
State if you are open to contributions and what your requirements are for accepting them.
First start only the Hashicorp Vault container from the compose file.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
```sh
$ docker compose up --build vault
```

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
Then access its UI at http://127.0.0.1:8200/ui/ and configure the sealing
shares. For development 1 key share with 1 key threshold is fine. The UI will
then show the shares and the root token, store all of them securely. Unseal
the vault.

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
At this point the vault is unsealed and the setup previously described can be
performed. The resulting token should be changed in the compose file. Stop the
compose command, and start again but this time with all services.

## License
For open source projects, say how it is licensed.
```sh
$ docker compose up --build
```

## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
At this point the Vault will need to be unsealed again, but after doing so
everything will be working normally and the secret controller will seal any
secret characteristics that are created.

ci_settings.xml

0 → 100644
+16 −0
Original line number Diff line number Diff line
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <servers>
    <server>
      <id>gitlab-maven</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>Job-Token</name>
            <value>${CI_JOB_TOKEN}</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>
</settings>
Loading