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

Implement User API #4407

Closed
akhenry opened this issue Oct 29, 2021 · 4 comments · Fixed by #4538
Closed

Implement User API #4407

akhenry opened this issue Oct 29, 2021 · 4 comments · Fixed by #4538

Comments

@akhenry
Copy link
Contributor

akhenry commented Oct 29, 2021

Introduce user "awareness" into Open MCT to enable user and role specific functionality such as role-specific home pages.

The specific details of how users are identified and authenticated will be platform specific, so we need an API that delegates those details to a "User Provider".

Here are some thoughts on how we can break this problem down:

  1. Introduce a new "User API" eg. openmct.user.getCurrentUser()
  2. Add a new plugin that adds an indicator that shows the name of the currently logged in user. This plugin would be installed by default, but should only show an indicator if a user provider is defined in the API.
  3. Add an example User Provider Plugin that exercises the new User API. This plugin could add a dialog that allows the user to identify themselves, and then displays the provided name in the indicator defined in step 2. This plugin will not be installed by default, and will just be provided as an example to developers

A separate issue will be created to integrate the new Open MCT User API with Yamcs' user API.

I have some initial thoughts on what the user API might look like, which we can iterate on. One key thing to note is that I think we only want to support a single user provider at a time? Unlike view, object, and telemetry providers where we need to support many.

// This is how the current user is checked (eg. from an indicator that displays the logged in user)
let user = openmct.user.getCurrentUser(); // Returns a promise that resolves with a user or undefined

// This is how the `getCurrentUser()` function might be implemented:
openmct.user.getCurrentUser = function() {
    if (!this.provider || this.provider.isLoggedIn) {
        return Promise.resolve(undefined);
    } else {
        return this.provider.getCurrentUser();
    }
}

// This is how a new user provider is registered
openmct.user.setUserProvider({
    isLoggedIn() {

    }
    async getCurrentUser() {
        return {
            id: 'some-user-id',
            fullName: '',
            homeUrl: '' // MAY be built dynamically, based on role.
        }
    }
    async hasRole(roleId) {
    }
});
@akhenry
Copy link
Contributor Author

akhenry commented Nov 10, 2021

@scottbell I think this is a good issue for you to pick up when you run out of other tasks. Happy to answer questions.

@jvigliotta
Copy link
Contributor

jvigliotta commented Dec 7, 2021

Testing

  • with no user provider installed, you should NOT see the user indicator
  • with ExampleUserProvider plugin installed, you should see the user indicator
  • the example user provider should give you a login form (username)
    • the user name should show in the indicator, when you login

charlesh88 added a commit that referenced this issue Jan 8, 2022
- Text, markup and CSS classes refined;
- Stubbed in password form row, commented out;
- Set overlay size to `fit`;
charlesh88 added a commit that referenced this issue Jan 8, 2022
- Removed `no-minify` from UserIndicator;
charlesh88 added a commit that referenced this issue Jan 8, 2022
- Stubbed in Login/Logout buttons in UserIndicator.vue;
@nikhilmandlik
Copy link
Contributor

Verified Fixed.

@akhenry
Copy link
Contributor Author

akhenry commented Jan 24, 2022

Verified fixed

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