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

refactor to add jwt cache and authenticator object #240

Merged
merged 22 commits into from
May 28, 2024

Conversation

techcobweb
Copy link
Contributor

@techcobweb techcobweb commented May 10, 2024

Signed-off-by: Mike Cobbett 77053+techcobweb@users.noreply.github.com

Why ?

This is part of this issue: Local test run to be able to use remote CPS
#1813

Tasks in this PR

  • Add a 'JWT cache' concept inside the authenticator, preparing the way to encrypt the data.
  • Add an authenticator class to pull together lots of tightly-bound functions
  • Logoff should accept a bootstrap flag to make it symmetrical abandoned because we want to move to a context and away from bootstrap
  • Logoff should remove the file using cache.clear rather than zapping the underlying file.
  • Move some interfaces to an spi folder so we can avoid cyclic dependencies easier.
  • The bearer token code in utils is the only thing which knows where bearer tokens are stored. (In the ~/.galasa/bearer-tokens folder)
  • The cache is the only thing which manipulates bearer tokens
  • Logout flushes all cache entries
  • A JWT in the cache which has expired is treated as not existing at all, so a new one can be allocated.
  • Linted the code a bit, and cleaned up some of the warnings.
  • Each server has it's own jwt stored in the cache. Stored in a folder whose name is the uuencoded api server URL. So they are unique files.
  • The files are encrypted before they are written to disk. Using the galasa token.
  • The files are accessed using exclusive lock access. So one tool instance can't interfere with another.

@galasa-team
Copy link

Build successful

@techcobweb techcobweb requested a review from eamansour May 10, 2024 16:17
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build failed, see http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/#/namespaces/galasa-build/pipelineruns/repo-cli-pr-240-299ws for details. If you are unable to do so, please contact a member of the Galasa team.

@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

1 similar comment
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build failed, see http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/#/namespaces/galasa-build/pipelineruns/repo-cli-pr-240-9wq8v for details. If you are unable to do so, please contact a member of the Galasa team.

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Copy link
Member

@eamansour eamansour left a comment

Choose a reason for hiding this comment

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

A couple of minor comments, but the changes are looking great!

pkg/auth/authLogin_test.go Outdated Show resolved Hide resolved
pkg/errors/errorMessage.go Outdated Show resolved Hide resolved
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

…he key

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
pkg/utils/crypto.go Fixed Show fixed Hide fixed
@galasa-team
Copy link

Build failed, see http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/#/namespaces/galasa-build/pipelineruns/repo-cli-pr-240-lbczh for details. If you are unable to do so, please contact a member of the Galasa team.

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build failed, see http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/#/namespaces/galasa-build/pipelineruns/repo-cli-pr-240-c8c86 for details. If you are unable to do so, please contact a member of the Galasa team.

Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
@galasa-team
Copy link

Build successful

@techcobweb techcobweb merged commit 6ac4d3a into main May 28, 2024
5 checks passed
@techcobweb techcobweb deleted the mcobbett-1813-add-jwtcache-and-authenticator branch May 28, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants