Skip to content
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

[DAPS, Foxx, Core] - Feature, adjust UserGetAccessRequest to work with Mapped Collection UUID #1215

Open
JoshuaSBrown opened this issue Jan 7, 2025 · 0 comments · May be fixed by #1284
Open
Assignees
Labels
Priority: High Highest priority

Comments

@JoshuaSBrown
Copy link
Collaborator

Description

This is in support of moving document to and from mapped collections. We need someway of checking to make sure that a token exists if a mapped collection is being used.

Does a token already exist if it is a mapped collection or do we need to trigger a consent flow.
To avoid latency issues, we should only check if the token is expired and not make calls to Globus.

Below is relevant content in the datafed-ws.js file, this should be adjusted in a separte issue, it is shown here to indicate the connection between the web server and the core service.

app.get('/ui/ep/dir/list', ( a_req, a_resp ) => {

    // Aaron should do some work here to determine the collection type

    // if it is a mapped collection – might need if statement, need to check if we need to go through consent flow or not
    // if it is a mapped collection Collection UUID and Collection type need to be included in UserGetAccessTokenRequest message
    // If token is already stored and not expired needs to be returned here.
    // If token is expired need to indicate if token is valid
    sendMessage( "UserGetAccessTokenRequest", {}, a_req, a_resp, function( reply ) {

        const opts = {
            hostname: 'transfer.api.globusonline.org',
            method: 'GET',
            path: '/v0.10/operation/endpoint/' + encodeURIComponent(a_req.query.ep) + '/ls?path=' + encodeURIComponent(a_req.query.path) + '&show_hidden=' + a_req.query.hidden,
            rejectUnauthorized: true,
            headers:{
                Authorization: ' Bearer ' + reply.access
            }
        };

        const req = https.request( opts, (res) => {
            var data = '';

            res.on('data', (chunk) => {
                data += chunk;
            });
            res.on('end', () => {
                a_resp.json(JSON.parse(data));
            });
        });

        req.on('error', (e) => {
            a_resp.status( 500 );
            a_resp.send( "Globus endpoint directoy listing failed." );
        });

        req.end();
    });

});

Four branches –

If token is in database for mapped collection, check expiration if valid return token, needs_consent bool is false
If token is in database for mapped collection, check expiration, if invalid use refresh token to create new access token, save in database, return needs_consent bool false
If token is in database for mapped collection, check expiration, if invalid refresh token fails, return needs_consent true
If token is not in database, return needs_consent: true

What needs to go in this if the access token does not exist for a mapped collection

message UserAccessTokenReply
{
required string access = 1; // Globus access token
required uint32 expires_in = 2; // Access token expiration in seconds
}

Acceptance

The four branches described above should work and have valid test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Highest priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants