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

Add OAuth & Token Authentication #19

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

mcurbelo-orangeloops
Copy link

No description provided.

mcurbelo-orangeloops and others added 27 commits March 22, 2022 16:47
Add convenience method for storing OAuth parameters
Hit /oauth/authenticate endpoint in server
Update authentication screen for error state
Add is_enabled flag to OAuth service
Add support for access tokens on legacy login
Remove duplicates of LAMP.configuration members
Use refresh token when access token expires
Revert authorization changes to keep compatibility with basic authentication
BIML-43 Update for Azure B2C compatibility
Fix multiple parallel token refreshes being allowed
Fix user not being logged out automatically when tokens can't be refreshed
Copy link
Member

@avaidyam avaidyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Only minor changes here that are mostly dependent on LAMP-server's PR.

import { Demo } from "./service/Demo"
import { Fetch } from "./service/Fetch"

import { decode } from "jsonwebtoken"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep LAMP-js clear of the actual OAuth/IdP stuff like JWTs, and instead offer alternate login methods where the API client user is expected to complete the IdP login and already have a long-lived (or short-lived!) token to provide instead of a password?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is to say, I think the extra functionality added here might belong in LAMP-dashboard only!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, we will have API clients log into the dashboard to pull the mindLAMP access token and paste it into their code. We'll think of an OOB flow later.

refreshToken: newAuth.refresh_token
}
})

export class Fetch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a much needed simplification of the Fetch class, thanks!

access_token: string | undefined,
refresh_token: string | undefined,
}
export class OAuthService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sessionStorage stuff here seems more for the dashboard codebase instead? The LAMP-js library needs to be usable if a data scientist wants to use NodeJS for their data analysis/visualization dashboard/etc.

}

const refreshToken = async (expiredToken: string) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels to me like the token refresh is automated where users will never have an automatic logout issue (i.e. once they manually log in, they should stay logged in until manually logging out), but is that going to be the case?

Copy link
Member

@avaidyam avaidyam Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should switch back to localStorage to avoid this issue - AFTER we consider the consequences of the native app's sessionStorage flow.

@@ -1,63 +1,105 @@
import LAMP from '../index'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought cyclic imports were not permitted - does this compile on older TS versions? (I suppose we don't need to worry about that technically though.)

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

Successfully merging this pull request may close these issues.

4 participants