-
Notifications
You must be signed in to change notification settings - Fork 549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
token: token, | ||
admin: admin, | ||
hasGitHubPAT: userInfo.extension.hasOwnProperty('githubPAT')&& Boolean(userInfo.extension['githubPAT']), | ||
hasGitHubPAT: userItem.extension.githubPAT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not need hasGitHubPAT
any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the current state of github pat feature.
I just keep the original logic and simplify the code.
if (token.username === username && token.application) { | ||
return token; | ||
} else { | ||
throw new Error('Invalid authorization header'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quiet understand for this line. In which situation, the HTTP authentication header will be "Basic credentials" #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return axios.create(config); | ||
}; | ||
|
||
const serialize = (object) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encode data to base64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an inner function and I think it won't be used by other components.
I prefer using a shorter function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some comments on them to improve code readability
}; | ||
|
||
|
||
const deserialize = (object) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decode data from base64
|
||
const createNamespace = async (namespace) => { | ||
const url = new URL(`/api/v1/namespaces/`, apiserver.uri).href; | ||
const config = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it deplicate with initClient ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a namespace api with different base uri.
Maybe it should be in another file like k8s-util.js
or k8s-namespace.js
.
I think we can reorganize the k8s api file structure later.
}); | ||
}; | ||
|
||
const purge = (data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete invalid token?
Token
Application Token
|
Changes
Token format
application
k8s secret
when authentication (check if it is revoked), theadmin
field in jwt is removed. The permission info will be retrieved dynamically fromk8s secret
Storage
pai-user-token
namespace ofk8s secret
Authentication error
Token is expired
error message is removed.token is invalid
error message will be shown now.k8s secret model
API routes
Test Cases
Token
Application Token
Tested in unit test "userToken.js"