determined icon indicating copy to clipboard operation
determined copied to clipboard

feat: create `long_lived_tokens` table, implement CRUD operations, create APIs

Open ShreyaLnuHpe opened this issue 1 year ago • 2 comments

Ticket

DET-10397 DET-10396 DET-10403

Description

Allowing users to create long lived tokens that they can use for authentication

Creating 'long_lived_tokens' table for tracking long-lived tokens that can be used for authentication & association with the appropriate user. Including CRUD operation functions on this table, leveraging the token id (id).

Table fields:

public.long_lived_tokens (
    id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    user_id integer NOT NULL,
    expires_at TIMESTAMP NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY(user_id) REFERENCES public.users(id) ON DELETE CASCADE
)

APIs: (WIP)

Test Plan

  • [x] Table creation
  • [x] Integration Tests of CRUD Ops
  • [ ] API creations (WIP)
  • [ ] E2E tests for APIs (TODO)

After migration, you can see the created 'long_lived_tokens' table, along with CRUD operations to support POST and DELETE operations.

Completed local tests

Migration to create a table of the given schema:

$ cd master/static/migrations
$ ./migration-create.sh add-long-lived-tokens-table
$ cd ~/Projects/determined/
$ master/build/determined-master --config-file /Users/shreya/Projects/determined/.circleci/devcluster/master.yaml migrate up 

Checklist

  • [X] Changes have been manually QA'd
  • [ ] New features have been approved by the corresponding PM
  • [ ] User-facing API changes have the "User-facing API Change" label
  • [ ] Release notes have been added as a separate file under docs/release-notes/ See Release Note for details.
  • [ ] Licenses have been included for new code which was copied and/or modified from any external code

ShreyaLnuHpe avatar Aug 26 '24 18:08 ShreyaLnuHpe

Deploy Preview for determined-ui canceled.

Name Link
Latest commit e386613122b88168c830f076bb88ae1825213034
Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/6711912ef664c00007ba8fbb

netlify[bot] avatar Aug 26 '24 18:08 netlify[bot]

Codecov Report

Attention: Patch coverage is 41.86047% with 250 lines in your changes missing coverage. Please review.

Project coverage is 54.37%. Comparing base (2ef2f12) to head (e386613). Report is 44 commits behind head on main.

Files with missing lines Patch % Lines
harness/determined/cli/token.py 16.16% 83 Missing :warning:
master/internal/token/authz_rbac.go 1.36% 72 Missing :warning:
master/internal/token/authz_basic_impl.go 4.16% 23 Missing :warning:
master/pkg/model/user.go 0.00% 22 Missing :warning:
master/internal/api_token.go 80.95% 20 Missing :warning:
master/internal/token/postgres_token.go 75.71% 17 Missing :warning:
master/internal/token/authz_permissive.go 10.00% 9 Missing :warning:
master/internal/api_auth.go 0.00% 2 Missing :warning:
master/internal/user/postgres_users.go 92.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9867      +/-   ##
==========================================
- Coverage   54.42%   54.37%   -0.05%     
==========================================
  Files        1262     1268       +6     
  Lines      158880   159302     +422     
  Branches     3631     3630       -1     
==========================================
+ Hits        86463    86626     +163     
- Misses      72283    72542     +259     
  Partials      134      134              
Flag Coverage Δ
backend 45.49% <49.54%> (+<0.01%) :arrow_up:
harness 72.55% <16.16%> (-0.20%) :arrow_down:
web 53.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
harness/determined/cli/cli.py 45.13% <ø> (ø)
master/internal/api_auth.go 41.26% <0.00%> (-0.34%) :arrow_down:
master/internal/user/postgres_users.go 81.10% <92.00%> (+0.59%) :arrow_up:
master/internal/token/authz_permissive.go 10.00% <10.00%> (ø)
master/internal/token/postgres_token.go 75.71% <75.71%> (ø)
master/internal/api_token.go 80.95% <80.95%> (ø)
master/pkg/model/user.go 23.30% <0.00%> (-4.62%) :arrow_down:
master/internal/token/authz_basic_impl.go 4.16% <4.16%> (ø)
master/internal/token/authz_rbac.go 1.36% <1.36%> (ø)
harness/determined/cli/token.py 16.16% <16.16%> (ø)

... and 5 files with indirect coverage changes

codecov[bot] avatar Aug 26 '24 18:08 codecov[bot]