Skip to content

Commit d4e3a80

Browse files
authored
Revert TMS change (#1069)
* Revert TMS change This reverts commit f4b5b90, reversing changes made to a2ba0dc.
1 parent 78c2e65 commit d4e3a80

10 files changed

Lines changed: 127 additions & 113 deletions

File tree

client/src/components/Applications/AppForm/AppForm.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ AppInfo.propTypes = {
233233

234234
export const AppSchemaForm = ({ app }) => {
235235
const dispatch = useDispatch();
236-
const { systemNeedsKeys, pushKeysSystem } = app;
237236

238237
useEffect(() => {
239238
dispatch({ type: 'GET_SYSTEM_MONITOR' });
@@ -256,7 +255,10 @@ export const AppSchemaForm = ({ app }) => {
256255
state.allocations
257256
);
258257
const { defaultHost, configuration, defaultSystem } = state.systems.storage;
259-
const keyService = pushKeysSystem?.defaultAuthnMethod === 'TMS_KEYS';
258+
259+
const keyService = state.systems.storage.configuration.find(
260+
(sys) => sys.system === defaultSystem && sys.default
261+
)?.keyservice;
260262

261263
const hasCorral =
262264
configuration.length &&
@@ -297,6 +299,8 @@ export const AppSchemaForm = ({ app }) => {
297299
(state) => state.workbench.config.hideManageAccount
298300
);
299301

302+
const { systemNeedsKeys, pushKeysSystem } = app;
303+
300304
const missingLicense = app.license.type && !app.license.enabled;
301305
const pushKeys = (e) => {
302306
e.preventDefault();

client/src/components/DataFiles/DataFilesTable/DataFilesTable.jsx

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ const DataFilesTablePlaceholder = ({ section, data }) => {
3434
(sysDef) => sysDef.id === state.files.params.FilesListing.system
3535
)
3636
);
37+
38+
const { fetchSelectedSystem } = useSystems();
39+
40+
const selectedSystem = fetchSelectedSystem(params ?? {});
41+
3742
const currSystemHost = currSystem ? currSystem.host : '';
3843

3944
const modalRefs = useSelector((state) => state.files.refs);
@@ -118,30 +123,29 @@ const DataFilesTablePlaceholder = ({ section, data }) => {
118123
['private', 'projects'].includes(scheme) &&
119124
currSystem?.effectiveUserId === currentUser
120125
) {
121-
const sectionMessage =
122-
currSystem?.defaultAuthnMethod === 'TMS_KEYS' ? (
123-
<span>
124-
For help, please{' '}
125-
<Link
126-
className="wb-link"
127-
to={`${ROUTES.WORKBENCH}${ROUTES.DASHBOARD}${ROUTES.TICKETS}/create`}
128-
>
129-
submit a ticket.
130-
</Link>
131-
</span>
132-
) : (
133-
<span>
134-
If this is your first time accessing this system, you may need to{' '}
135-
<a
136-
className="data-files-nav-link"
137-
type="button"
138-
href="#"
139-
onClick={pushKeys}
140-
>
141-
push your keys
142-
</a>
143-
</span>
144-
);
126+
const sectionMessage = selectedSystem?.keyservice ? (
127+
<span>
128+
For help, please{' '}
129+
<Link
130+
className="wb-link"
131+
to={`${ROUTES.WORKBENCH}${ROUTES.DASHBOARD}${ROUTES.TICKETS}/create`}
132+
>
133+
submit a ticket.
134+
</Link>
135+
</span>
136+
) : (
137+
<span>
138+
If this is your first time accessing this system, you may need to{' '}
139+
<a
140+
className="data-files-nav-link"
141+
type="button"
142+
href="#"
143+
onClick={pushKeys}
144+
>
145+
push your keys
146+
</a>
147+
</span>
148+
);
145149

146150
return (
147151
<div className="h-100 listing-placeholder">

server/poetry.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/portal/apps/accounts/api/views/systems.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.utils.decorators import method_decorator
1010
from portal.views.base import BaseApiView
1111
from portal.apps.accounts.managers import accounts as AccountsManager
12-
from portal.apps.onboarding.steps.system_access_v3 import create_system_credentials_with_keys
12+
from portal.apps.onboarding.steps.system_access_v3 import create_system_credentials
1313
from portal.utils.encryption import createKeyPair
1414

1515
logger = logging.getLogger(__name__)
@@ -52,11 +52,11 @@ def push(self, request, system_id, body):
5252
hostname=body['form']['hostname']
5353
)
5454

55-
create_system_credentials_with_keys(request.user.tapis_oauth.client,
56-
request.user.username,
57-
publ_key_str,
58-
priv_key_str,
59-
system_id)
55+
create_system_credentials(request.user.tapis_oauth.client,
56+
request.user.username,
57+
publ_key_str,
58+
priv_key_str,
59+
system_id)
6060

6161
return JsonResponse(
6262
{

server/portal/apps/onboarding/steps/system_access_v3.py

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import logging
2+
import requests
3+
from requests.exceptions import HTTPError
24
from portal.apps.onboarding.steps.abstract import AbstractStep
35
from portal.apps.onboarding.state import SetupState
6+
from django.conf import settings
7+
from portal.utils.encryption import createKeyPair
48
from portal.libs.agave.utils import service_account
59
from tapipy.errors import BaseTapyException
6-
from portal.utils.encryption import createKeyPair
10+
711

812
logger = logging.getLogger(__name__)
913

1014

11-
def create_system_credentials_with_keys(client,
12-
username,
13-
public_key,
14-
private_key,
15-
system_id,
16-
skipCredentialCheck=False) -> int:
15+
def create_system_credentials(client,
16+
username,
17+
public_key,
18+
private_key,
19+
system_id,
20+
skipCredentialCheck=False) -> int:
1721
"""
1822
Set an RSA key pair as the user's auth credential on a Tapis system.
1923
"""
20-
logger.info(f"Creating user credential for {username} on Tapis system {system_id} using keys")
24+
logger.info(f"Creating user credential for {username} on Tapis system {system_id}")
2125
data = {'privateKey': private_key, 'publicKey': public_key}
2226
client.systems.createUserCredential(
2327
systemId=system_id,
@@ -27,21 +31,16 @@ def create_system_credentials_with_keys(client,
2731
)
2832

2933

30-
def create_system_credentials(client,
31-
username,
32-
system_id,
33-
createTmsKeys,
34-
skipCredentialCheck=False) -> int:
34+
def register_public_key(username, publicKey, system_id) -> int:
3535
"""
36-
Create user's auth credential on a Tapis system. This Tapis API uses TMS.
36+
Push a public key to the Key Service API.
3737
"""
38-
logger.info(f"Creating user credential for {username} on Tapis system {system_id} using TMS")
39-
client.systems.createUserCredential(
40-
systemId=system_id,
41-
userName=username,
42-
createTmsKeys=createTmsKeys,
43-
skipCredentialCheck=skipCredentialCheck,
44-
)
38+
url = "https://api.tacc.utexas.edu/keys/v2/" + username
39+
headers = {"Authorization": "Bearer {}".format(settings.KEY_SERVICE_TOKEN)}
40+
data = {"key_value": publicKey, "tags": [{"name": "system", "value": system_id}]}
41+
response = requests.post(url, json=data, headers=headers)
42+
response.raise_for_status()
43+
return response.status_code
4544

4645

4746
def set_user_permissions(user, system_id):
@@ -78,12 +77,6 @@ def prepare(self):
7877
self.state = SetupState.PENDING
7978
self.log("Awaiting TACC systems access.")
8079

81-
def get_system(self, system_id) -> None:
82-
"""
83-
Get the system definition
84-
"""
85-
return self.user.tapis_oauth.client.systems.getSystem(systemId=system_id)
86-
8780
def check_system(self, system_id) -> None:
8881
"""
8982
Check whether a user already has access to a storage system by attempting a listing.
@@ -108,17 +101,21 @@ def process(self):
108101
except BaseTapyException:
109102
self.log(f"Creating credentials for system: {system}")
110103

111-
system_definition = self.get_system(system)
104+
(priv, pub) = createKeyPair()
105+
106+
try:
107+
register_public_key(self.user.username, pub, system)
108+
self.log(f"Successfully registered public key for system: {system}")
109+
except HTTPError as e:
110+
logger.error(e)
111+
self.fail(f"Failed to register public key with key service for system: {system}")
112+
112113
try:
113-
if system_definition.get("defaultAuthnMethod") != 'TMS_KEYS':
114-
(priv, pub) = createKeyPair()
115-
create_system_credentials_with_keys(
116-
self.user.tapis_oauth.client, self.user.username, pub, priv, system
117-
)
118-
else:
119-
create_system_credentials(
120-
self.user.tapis_oauth.client, self.user.username, system, createTmsKeys=True
121-
)
114+
create_system_credentials(self.user.tapis_oauth.client,
115+
self.user.username,
116+
pub,
117+
priv,
118+
system)
122119
self.log(f"Successfully created credentials for system: {system}")
123120
except BaseTapyException as e:
124121
logger.error(e)

server/portal/apps/projects/workspace_operations/shared_workspace_operations.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Literal
55
from django.conf import settings
66
from django.contrib.auth import get_user_model
7+
# from portal.apps.onboarding.steps.system_access_v3 import create_system_credentials, register_public_key
78

89

910
import logging
@@ -182,6 +183,16 @@ def create_shared_workspace(client: Tapis, title: str, owner: str, **kwargs):
182183

183184
# User creates the system and adds their credential
184185
system_id = create_workspace_system(client, workspace_id, title)
186+
# priv_key, pub_key = createKeyPair()
187+
# register_public_key(owner,
188+
# pub_key,
189+
# system_id)
190+
# create_system_credentials(client, owner, pub_key, priv_key, system_id)
191+
# create_system_credentials(service_client,
192+
# settings.PORTAL_ADMIN_USERNAME,
193+
# settings.PORTAL_PROJECTS_PUBLIC_KEY,
194+
# settings.PORTAL_PROJECTS_PRIVATE_KEY,
195+
# system_id)
185196

186197
return system_id
187198

@@ -201,6 +212,14 @@ def add_user_to_workspace(client: Tapis,
201212
"add",
202213
role)
203214

215+
# Code to generate/push user keys to a workspace
216+
# (uncomment to add per-user credentials)
217+
# priv_key, pub_key = createKeyPair()
218+
# register_public_key(username,
219+
# pub_key,
220+
# system_id)
221+
# create_system_credentials(client, username, pub_key, priv_key, system_id)
222+
204223
# Share system to allow listing of users
205224
client.systems.shareSystem(systemId=system_id, users=[username])
206225
set_workspace_permissions(client, username, system_id, role)
Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
from portal.apps.onboarding.steps.system_access_v3 import create_system_credentials
2-
from tapipy.errors import BaseTapyException
31
import json
4-
import logging
5-
6-
logger = logging.getLogger(__name__)
72

83

94
def get_tapis_timeout_error_messages(job_id):
@@ -31,30 +26,3 @@ def check_job_for_timeout(job):
3126
job.remoteOutcome = 'FINISHED'
3227

3328
return job
34-
35-
36-
def should_push_keys(system):
37-
"""
38-
If defaultAuthnMethod is not TMS_KEYS, return true. Otherwise, false.
39-
"""
40-
return system.get("defaultAuthnMethod") != 'TMS_KEYS'
41-
42-
43-
def test_system_credentials(system, user):
44-
"""
45-
If system does not support TMS, create keys and
46-
tapis system credentials using keys, otherwise create
47-
credentials with TMS.
48-
"""
49-
# TODOv3: Add Tapis system test utility method with proper error handling https://tacc-main.atlassian.net/browse/WP-101
50-
tapis = user.tapis_oauth.client
51-
if should_push_keys(system):
52-
return False
53-
else:
54-
try:
55-
create_system_credentials(user.tapis_oauth.client, user.username, system.id, createTmsKeys=True)
56-
tapis.files.listFiles(systemId=system.id, path="/")
57-
except BaseTapyException:
58-
return False
59-
60-
return True

0 commit comments

Comments
 (0)