-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add Personal Access Tokens (PAT) for CLI/API authentication #495
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
Open
rossigee
wants to merge
9
commits into
container-registry:main
Choose a base branch
from
rossigee:feature/personal-access-tokens-pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3a9607
feat(pat): Add Personal Access Tokens (PAT) For CLI/API Authentication
rossigee b29eaa6
fix(pat): Populate Scope For Migrated Legacy PATs And Wire Up The Mig…
rossigee d953ead
fix(oidc): Fail Closed When Group Membership Sync Fails
rossigee 5f1c3eb
fix(test): Stop Logging PAT Secrets And Fix Wrong Expiry Field In PAT…
rossigee 854b883
chore(pat): Drop Redundant Index And Fix ListBySecretPrefix Doc Comment
rossigee 08de594
fix(api): Restore Personal Access Token Path/Schema Definitions In sw…
rossigee 4b3cd4e
fix(pat): Populate GroupIDs Before ListRoles In computeScope
rossigee b616684
fix(pat): Fail Startup On Migration Errors, Fix TOCTOU In CLI-Secret …
rossigee 9d2b03d
feat(portal): Implement Personal Access Token Management UI
rossigee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| -- Personal Access Tokens table for all auth modes (OIDC, DB, LDAP) | ||
| CREATE TABLE IF NOT EXISTS personal_access_token ( | ||
| id BIGSERIAL PRIMARY KEY NOT NULL, | ||
| user_id integer NOT NULL REFERENCES harbor_user(user_id), | ||
| name varchar(255) NOT NULL, | ||
| secret varchar(2048) NOT NULL, | ||
| salt varchar(64) NOT NULL, | ||
| description varchar(1024), | ||
| expires_at bigint NOT NULL DEFAULT -1, | ||
| last_used_at bigint, | ||
| disabled boolean NOT NULL DEFAULT false, | ||
| is_legacy boolean NOT NULL DEFAULT false, | ||
| creation_time timestamp DEFAULT CURRENT_TIMESTAMP, | ||
| update_time timestamp DEFAULT CURRENT_TIMESTAMP, | ||
| CONSTRAINT unique_pat_name UNIQUE (user_id, name) | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_pat_user_id ON personal_access_token (user_id); | ||
| CREATE INDEX IF NOT EXISTS idx_pat_disabled ON personal_access_token (disabled); | ||
|
|
||
| CREATE TRIGGER pat_update_time_at_modtime | ||
| BEFORE UPDATE ON personal_access_token FOR EACH ROW | ||
| EXECUTE PROCEDURE update_update_time_at_column(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Remove scope column from personal_access_token table | ||
| ALTER TABLE personal_access_token DROP COLUMN IF EXISTS scope; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Add scope column to personal_access_token table | ||
| ALTER TABLE personal_access_token ADD COLUMN IF NOT EXISTS scope TEXT; |
3 changes: 3 additions & 0 deletions
3
make/migrations/postgresql/0202_2.17.0_pat_secret_prefix.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Remove secret_prefix column | ||
| DROP INDEX IF EXISTS idx_pat_secret_prefix; | ||
| ALTER TABLE personal_access_token DROP COLUMN IF EXISTS secret_prefix; |
3 changes: 3 additions & 0 deletions
3
make/migrations/postgresql/0202_2.17.0_pat_secret_prefix.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Add secret_prefix column for efficient PAT lookup | ||
| ALTER TABLE personal_access_token ADD COLUMN IF NOT EXISTS secret_prefix VARCHAR(8); | ||
| CREATE INDEX IF NOT EXISTS idx_pat_secret_prefix ON personal_access_token(secret_prefix) WHERE secret_prefix IS NOT NULL; | ||
3 changes: 3 additions & 0 deletions
3
make/migrations/postgresql/0203_2.17.0_user_group_membership.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Drop user_group_membership table | ||
| DROP INDEX IF EXISTS idx_user_group_membership_user_id; | ||
| DROP TABLE IF EXISTS user_group_membership; |
9 changes: 9 additions & 0 deletions
9
make/migrations/postgresql/0203_2.17.0_user_group_membership.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| -- Create user_group_membership table to persist external auth group memberships | ||
| CREATE TABLE IF NOT EXISTS user_group_membership ( | ||
| user_id INTEGER NOT NULL, | ||
| group_id INTEGER NOT NULL, | ||
| creation_time TIMESTAMP NOT NULL DEFAULT NOW(), | ||
| PRIMARY KEY (user_id, group_id) | ||
| ); | ||
| -- No separate index on user_id: the (user_id, group_id) primary key | ||
| -- already supports lookups filtered by user_id alone. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.