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

Git Token Based Authentication #192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Catalin-Stratulat-Ericsson
Copy link
Contributor

@Catalin-Stratulat-Ericsson Catalin-Stratulat-Ericsson commented Mar 5, 2025

This PR adds the ability for the porch server to utilize secrets with tokens (Personal Access Tokens) and use those in authentication with the git instance instead of just basic authentication using username & password in porch repositories.
Documentation Relating to these changes can be found in PR#221

Copy link
Contributor

nephio-prow bot commented Mar 5, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Catalin-Stratulat-Ericsson
Once this PR has been reviewed and has the lgtm label, please assign johnbelamaric for approval by writing /assign @johnbelamaric in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nephio-prow nephio-prow bot requested review from s3wong and tliron March 5, 2025 15:38
@Catalin-Stratulat-Ericsson Catalin-Stratulat-Ericsson requested review from kispaljr, liamfallon and efiacor and removed request for s3wong and tliron March 5, 2025 15:38
Copy link

sonarqubecloud bot commented Mar 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
32.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@@ -43,6 +44,9 @@ const (

//Secret.Data key required for the caBundle
CaBundleDataName = "ca.crt"

//Secret.Data key substring required for the token
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//Secret.Data key substring required for the token
// Secret.Data key substring required for the token

var _ repository.Credential = &TokenAuthCredentials{}

func (b *TokenAuthCredentials) Valid() bool {
return true
Copy link
Member

Choose a reason for hiding this comment

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

Just checking is this OK? Is there nothing to validate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see i think this might just be a misworded function name because the basic-auth(username & password resolver & ca bundle resolver both return true for this method also) only the gcw resolver returns the following.

func (b *GcloudWICredential) Valid() bool 
{
	timeLeft := time.Until(b.token.Expiry)
	return timeLeft > 5*time.Minute
}

which to me means that check if the value is still valid based on a time interval/expiry mechanism which i dont believe apply in the other cases?
maybe a different name for the function something like expiryValidity() or something along the lines if my understanding is correct?

Copy link
Member

Choose a reason for hiding this comment

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

I think any checks we can do on validity or expiry of the token would be good.

Does the method not have to be called Valid()? I assume this must be an implementation of an interface that is being called by someone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in theory yes but this commit only allows the use of git tokens such as personal access tokens which is what we are using since were interacting with git instances for services such as github, gitlab, gitea etc and i believe these type of tokens do not actually include the expiry date in the token itself (just the key which to use) but rather manage this on the server side of the git instance itself.
As such the only way to know if the token is valid(expiry or by the value of the key itself) is to actually attempt to communicate with the git instance itself which is done after this process which simply checks that the secret data given matches what were looking for and is configured in the right way to feed it as an auth to this attempt at communicating with git

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if lets say we added JWT or perhaps other types of tokens to our list and added ability to process them which could contain other data within their token string such as the expiration date etc then another Resolver would have to be created and that Resolver Valid() method could process that information and return a more accurate validity check instead of just returning true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants