hawtio / hawtio-oauth

OAuth integration plugins for hawtio 2.x
Apache License 2.0
6 stars 14 forks source link

Provide a generic API function across plugins that plugins can use to re-direct to the oauth provider login page #7

Closed gashcrumb closed 9 years ago

gashcrumb commented 9 years ago

Currently oauth plugins themselves handle redirects to the oauth provider login page, but there's no way for plugins to do a redirect without resorting to provider specific code. We should add an overall 'HawtioOAuth' module with an API that plugins can use to trigger a redirect without having to depend on specific provider code.

gashcrumb commented 9 years ago

There's now a facade module in plugins/includes.ts that provides a couple API functions that plugins can use:

authenticatedHttpRequest(options:any) calls $.ajax() under the covers and returns the promise object, use to make a call with the active provider's token if present. getOAuthToken() returns the active provider's token. getUserProfile() returns the active provider's user profile that's also merged into the userDetails service after angular is bootstrapped. doLogout() makes the active provider clear it's token storage and re-direct to the login screen.