Skip to content

Conversation

@nghialv
Copy link
Member

@nghialv nghialv commented Dec 6, 2020

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #1192

Does this PR introduce a user-facing change?:

NONE

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

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

GO_LINTER

Some issues were detected while linting go source files in your changes.

key *model.APIKey
}

func (v testAPIKeyVerifier) Verify(ctx context.Context, key string) (*model.APIKey, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ctx is unused in Verify

Copy link
Member

Choose a reason for hiding this comment

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

@nghialv plz resolve this before get merge 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it.


const (
apiKeyLength = 50
apiKeyLength = 32
Copy link
Member

@khanhtc1202 khanhtc1202 Dec 6, 2020

Choose a reason for hiding this comment

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

does this change due to some change in requirement? 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, I'm wondering about the APIKey's length.
Currently, the returned APIKey contains 2 parts like this "UUID-PART.RANDOM-PART".

  • The first part is a UUID string used as the key's ID with a length of 32 characters.
  • The second part is a random string used as the key's password.

If the random part is 50 characters then the whole APIKey looks pretty long.
So I reduced the length of that part to 32 and the entire length of the APIKey is 64 characters.

(Not sure, but maybe we also should encrypt the APIKey (e.g. base64) to get a better look 🤔 )

Copy link
Member

@khanhtc1202 khanhtc1202 Dec 7, 2020

Choose a reason for hiding this comment

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

(Not sure, but maybe we also should encrypt the APIKey (e.g. base64) to get a better look 🤔 )

I think it would be better if the key has a specific length in all cases, will reduce other issues around miss/conflict setting. What do you think? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. Nice catch!

Copy link
Member

Choose a reason for hiding this comment

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

let's address it by another PR 😄

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.56%. This pull request increases coverage by 0.29%.

File Function Base Head Diff
pkg/app/api/apikeyverifier/verifier.go NewVerifier -- 100.00% +100.00%
pkg/app/api/apikeyverifier/verifier.go Verifier.Verify -- 77.78% +77.78%
pkg/app/api/apikeyverifier/verifier.go checkAPIKey -- 100.00% +100.00%
pkg/rpc/rpcauth/interceptor.go APIKeyUnaryServerInterceptor -- 84.62% +84.62%
pkg/rpc/rpcauth/interceptor.go ExtractAPIKey -- 75.00% +75.00%
pkg/rpc/server.go WithAPIKeyAuthUnaryInterceptor -- 0.00% +0.00%
pkg/model/apikey.go APIKey.CompareKey 60.00% 80.00% +20.00%
pkg/rpc/rpcauth/auth.go extractCredentials 95.45% 95.83% +0.38%
pkg/rpc/server.go Server.init 74.07% 72.41% -1.66%

@khanhtc1202
Copy link
Member

/approve
🚀 🚀 🚀

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.56%. This pull request increases coverage by 0.29%.

File Function Base Head Diff
pkg/app/api/apikeyverifier/verifier.go NewVerifier -- 100.00% +100.00%
pkg/app/api/apikeyverifier/verifier.go Verifier.Verify -- 77.78% +77.78%
pkg/app/api/apikeyverifier/verifier.go checkAPIKey -- 100.00% +100.00%
pkg/rpc/rpcauth/interceptor.go APIKeyUnaryServerInterceptor -- 84.62% +84.62%
pkg/rpc/rpcauth/interceptor.go ExtractAPIKey -- 75.00% +75.00%
pkg/rpc/server.go WithAPIKeyAuthUnaryInterceptor -- 0.00% +0.00%
pkg/model/apikey.go APIKey.CompareKey 60.00% 80.00% +20.00%
pkg/rpc/rpcauth/auth.go extractCredentials 95.45% 95.83% +0.38%
pkg/rpc/server.go Server.init 74.07% 72.41% -1.66%

@pipecd-bot pipecd-bot merged commit d7458b7 into master Dec 7, 2020
@pipecd-bot pipecd-bot deleted the api-key-auth branch December 7, 2020 05:01
@pipecd-bot pipecd-bot mentioned this pull request Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement authentication logic for API key

4 participants