ARGA-Genomes / arga-web

Monorepo for ARGA web components and API wrappers
Mozilla Public License 2.0
1 stars 0 forks source link

Add user authentication #25

Open nickdos opened 2 years ago

nickdos commented 2 years ago

Jack has a sample React project that uses the ALA OIDC authentication service:

https://github.com/AtlasOfLivingAustralia/ala-oidc-react

Basically, all that needs to be done to implement it is: Add AuthProvider wrapper to the app component (see here, optionally load the clientID etc from config), and then just use the useAuth hook and call the signIn / signOut functions (see here)

Could also write your own API provider which is a child component of the Auth provider, and make it call the useAuth hook and automagically add the Bearer token to all requires

You define the actual context values in the Producer component. You can use the useContext hook & pass in the context value to access that data from anywhere. The cheeky part is, since the producer is a react component, you can have state values and use hooks to update the context value. If you were to make an API context, you can call the useAuth hook from it's producer component & check whether the user is authenticated & retrieve the bearer token. The values you would provide to the context could be functions that make API calls, generated by the Producer component with the bearer token automatically included in the header. Example of it here.


Enhancements to authentication and user profile features

nickdos commented 2 years ago

Done - PR merged.

nickdos commented 2 years ago

Adding some enhancements to this issue...

nickdos commented 2 years ago

Investigating if we should get on the test/dev server for CI logon (same as BPA/Galaxy).