Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Add authorization to GO library #554

Conversation

lukasmittag
Copy link
Contributor

No description provided.

@lukasmittag lukasmittag linked an issue May 11, 2023 that may be closed by this pull request
If you want the GO client to work with the KUKSA.val server specify protocol as ws if you want to use the KUKSA.val databroker set protocol to grpc. On command line it's available thorugh -protocol ws/grpc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not "thorugh" I assume? The first sentence could also benefit from rephrasing, or a dot/period after as ws

@lukasmittag lukasmittag force-pushed the feature/go_client_authorization branch 2 times, most recently from bf153f2 to 6b167b5 Compare May 12, 2023 06:30
var token string
if *protocol == "ws" {
// example token from kuksa.val/kuksa_certificates/jwt/all-read-write.json.token
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJrdWtzYS52YWwiLCJpc3MiOiJFY2xpcHNlIEtVS1NBIERldiIsImFkbWluIjp0cnVlLCJpYXQiOjE1MTYyMzkwMjIsImV4cCI6MTc2NzIyNTU5OSwia3Vrc2EtdnNzIjp7IioiOiJydyJ9fQ.QQcVR0RuRJIoasPXYsMGZhdvhLjUalk4GcRaxhh3-0_j3CtVSZ0lTbv_Z3As5BfIYzaMlwUzFGvCVOq2MXVjRK81XOAZ6wIsyKOxva16zjbZryr2V_m3yZ4twI3CPEzJch11_qnhInirHltej-tGg6ySfLaTYeAkw4xYGwENMBBhN5t9odANpScZP_xx5bNfwdW1so6FkV1WhpKlCywoxk_vYZxo187d89bbiu-xOZUa5D-ycFkd1-1rjPXLGE_g5bc4jcQBvNBc-5FDbvt4aJlTQqjpdeppxhxn_gjkPGIAacYDI7szOLC-WYajTStbksUju1iQCyli11kPx0E66me_ZVwOX07f1lRF6D2brWm1LcMAHM3bQUK0LuyVwWPxld64uSAEsvSKsRyJERc7nZUgLf7COnUrrkxgIUNjukbdT2JVN_I-3l3b4YXg6JVD7Y5g0QYBKgXEFpZrDbBVhzo7PXPAhJD6-c3DcUQyRZExbrnFV56RwWuExphw8lYnbMvxPWImiVmB9nRVgFKD0TYaw1sidPSSlZt8Uw34VZzHWIZQAQY0BMjR33fefg42XQ1YzIwPmDx4GYXLl7HNIIVbsRsibKaJnf49mz2qnLC1K272zXSPljO11Ke1MNnsnKyUH7mcwEs9nhTsnMgEOx_TyMLRYo-VEHBDLuEOiBo"
Copy link
Contributor

Choose a reason for hiding this comment

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

The hard-coded token here means that we practically ignore what has been defined in https://github.com/eclipse/kuksa.val/blob/master/kuksa_go_client/kuksa-client.json right? As we only use it as backup? Or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but since these are some examples how to use the go client, I thought this would be the best way to showcase it.

func (cg *KuksaClientCommGrpc) AuthorizeKuksaValConn(TokenOrTokenfile string) error {
var tokenString string
if TokenOrTokenfile == "" {
if cg.Config.TokenOrTokenfile != ""{
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be an idea to reverse the logic here

if cg.Config.TokenOrTokenfile != ""

else

Then we have no "dead" code, and one could actually use the config in https://github.com/eclipse/kuksa.val/blob/master/kuksa_go_client/kuksa-client.json (which by the way needs a changed keyword for "token", and also another port if the default is for a kuksa-val server connection (port 8090)

@erikbosch
Copy link
Contributor

I have verified:

  • Running towards server and databroker with hardcoded tokens
  • Running with token file specified in config file (after removing hardcoded token)

@erikbosch erikbosch force-pushed the feature/go_client_authorization branch from 6b167b5 to 3b42f4b Compare May 16, 2023 13:44
Copy link
Contributor

@erikbosch erikbosch left a comment

Choose a reason for hiding this comment

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

I have reviewed the original changes and have tested towards both databroker and server.
As Lukas is on vacation I have performed the updates I requested.

Tests performed for both Broker and Server:

  • Using hardcoded token from code
  • Using token file specified in config file
  • Checking that you get an error (although not always easy to understand if tokenfile in config does not exist

@erikbosch
Copy link
Contributor

@SebastianSchildt - As I did some updates on the PR from Lukas I think it would be good if you could do a sanity check, and if ok merge

Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

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

Did some basic checks, runs for me as well

@SebastianSchildt SebastianSchildt merged commit 4aa6985 into eclipse-archived:master May 16, 2023
@erikbosch erikbosch deleted the feature/go_client_authorization branch February 27, 2024 11:48
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support authorization in GO library
3 participants