OHDSI / OHDSI/WebAPI

The /user/refresh endpoint triggers session.stop()

Open
#2,344 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
151
Forks
183
Avg merge
14m
Merged PRs (30d)
2

Description

Expected behavior

Session should only be removed when logging out, or upon expiration.

Actual behavior

Because of a call to session.stop() in src/main/java/org/ohdsi/webapi/shiro/filters/UpdateAccessTokenFilter.java(see
https://github.com/uc-cdis/WebAPI/commit/32e90bc0df31ab692c3167ec9c17ba500780821a#diff-2ab1eba233c07d9653dbc0312742cf31baea8a755f797445784064efa44f88f9L118-L122), the session is removed in endpoints where it should not (like /user/refresh).

Steps to reproduce behavior

Run latest webapi w/ openid for example. Any attempt to retrieve session information after the filter above has been triggered as part of a later /user/refresh will fail with org.apache.shiro.subject.support.DisabledSessionException. Try for example the following steps:

  1. add some code like this to a custom filter that runs after UPDATE_TOKEN in the /user/refresh endpoint
    Subject subject = SecurityUtils.getSubject();
    return subject.getSession().getId().toString();
  1. setup openid based authentication
  2. login, go to cohorts, try to create and save a new cohort. This should trigger UpdateAccessTokenFilter again and the error reported here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/main/java/org/ohdsi/webapi/shiro/filters/UpdateAccessTokenFilter.java and follow the /user/refresh flow described in the reproduction steps. Verify that session information remains available after the filter runs during refresh, while session removal still occurs on logout or expiration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.