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

Adapt the keycloak startup script #541

Open
JohannesLichtenberger opened this issue Oct 22, 2022 · 7 comments
Open

Adapt the keycloak startup script #541

JohannesLichtenberger opened this issue Oct 22, 2022 · 7 comments

Comments

@JohannesLichtenberger
Copy link
Member

We first have to check if an admin user already exists in this script: https://github.com/sirixdb/sirix/blob/master/bundles/sirix-rest-api/src/test/resources/create-sirix-users.sh

@Aditya31398
Copy link

Hi @JohannesLichtenberger, I am a first timer. Can I work on this?

@JohannesLichtenberger
Copy link
Member Author

Sure :-)

@Aditya31398
Copy link

Aditya31398 commented Oct 27, 2022

Hi @JohannesLichtenberger, can you brief over the issue and let me know what changes are required?

@JohannesLichtenberger
Copy link
Member Author

The user should only be added if the user hasn't been added before, thus, first check if user exists, if not create the user

@JohannesLichtenberger
Copy link
Member Author

@Aditya31398, do you like and have time to work on the issue?

@Aditya31398
Copy link

@JohannesLichtenberger, sorry for the delay. I did look into the keycloak documentation. I was thinking we could do something like the below code.

if [ "$(opt/jboss/keycloak/bin/kcadm.sh get users -r sirixdb -q username=admin)" != '[ ]' ]; then echo 'User F
ound'; else opt/jboss/keycloak/bin/add-user-keycloak.sh -r sirixdb -u admin -p admin --roles create,modify,delete,view; fi;

In order to get the list of users we have to connect to the server prior to running the command. This can be achieved using the config credentials command which is available in the kcadm.sh . The below command can be used for connecting to the server.

opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin

Do let me know your views on this approach. Post that I can create a PR for the changes. If this is the right approach, can you also help with the parameters used for config credential command.

@JohannesLichtenberger
Copy link
Member Author

The script is copied into a startup folder of keycloak, so we might be able to simply copy your code:

volumes:
      - ./bundles/sirix-rest-api/src/test/resources/realm-export.json:/opt/keycloak/realm-export.json
      - ./bundles/sirix-rest-api/src/test/resources/create-sirix-users.sh:/opt/jboss/startup-scripts/create-sirix-users.sh

Aditya31398 added a commit to Aditya31398/sirix that referenced this issue Nov 5, 2022
Added Check admin user exists before creating new admin user
Aditya31398 added a commit to Aditya31398/sirix that referenced this issue Nov 7, 2022
Added config credentials Command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants