-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
custom AuthConnector for OAuth2 #28004
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
this is for #27913 |
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 👍
The new API surface looks alright and we can go ahead with this. Just a bunch of nits now that these things around about to become public API, things we don't care about as much for internal APIs.
packages/core-app-api/report.api.md
Outdated
authConnectorFactory?: ( | ||
opts: OAuth2CreateOptions, | ||
) => AuthConnector<OAuth2Session>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just be authConnector?: AuthConnector<OAuth2Session>
? The opts
type isn't really correct since these fields have been defaulted, but we wouldn't want to add another type. Overall it seems a bit unnecessary to wrap up like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, got it. The downside of providing ready AuthConnector
is that user must take care of providing same scopeTransform
option to both OAuth2#create(...)
and in the passed connector.
packages/core-app-api/report.api.md
Outdated
export type LoginPopupOptions = { | ||
url: string; | ||
name: string; | ||
origin: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this into showLoginPopup
to be derived from the url
instead?
packages/core-app-api/report.api.md
Outdated
@@ -478,6 +491,15 @@ export class LocalStorageFeatureFlags implements FeatureFlagsApi { | |||
save(options: FeatureFlagsSaveOptions): void; | |||
} | |||
|
|||
// @public | |||
export type LoginPopupOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this one to ShowLoginPopupOptions
, or matching w/e name the function ends up with
packages/core-app-api/report.api.md
Outdated
@@ -637,6 +662,9 @@ export class SamlAuth | |||
signOut(): Promise<void>; | |||
} | |||
|
|||
// @public | |||
export function showLoginPopup(options: LoginPopupOptions): Promise<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking openLoginPopup
might be a better name for this one?
It needs a more explicit return type as well, can't have any
. Needs to either be narrowed down or switched to unknown
packages/core-app-api/report.api.md
Outdated
@@ -353,6 +360,12 @@ export function createFetchApi(options: { | |||
middleware?: FetchMiddleware | FetchMiddleware[] | undefined; | |||
}): FetchApi; | |||
|
|||
// @public (undocumented) | |||
export type CreateSessionOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this ot AuthConnectorCreateSessionOptions
packages/core-app-api/report.api.md
Outdated
// @public | ||
export type AuthConnector<AuthSession> = { | ||
createSession(options: CreateSessionOptions): Promise<AuthSession>; | ||
refreshSession(scopes?: Set<string>): Promise<AuthSession>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you wrap this one up in options as well? So options?: AuthConnectorRefreshSessionOptions
with scopes
inside
.changeset/brave-pandas-beam.md
Outdated
@@ -0,0 +1,5 @@ | |||
--- | |||
'@backstage/core-app-api': patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna be a minor
for this one given the new API
.changeset/brave-pandas-beam.md
Outdated
'@backstage/core-app-api': patch | ||
--- | ||
|
||
custom AuthConnector for OAuth2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fill this out a little bit more please?
Hey guys, thanks a lot for the comments, I will take a look at them and update as soon as I am back from vacation (jan 6). I leave this comment here so that PR won't automatically close. |
This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution! |
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
@Rugvip I updated the PR, please check. |
@gusega did you mark it as draft to indicate it's still being worked on and not ready for review? |
@freben I want to add a unit test. I will mark it as ready after that. |
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
Please review. |
Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
Hey, I just made a Pull Request!
Provide custom authConnector to Oauth2
✔️ Checklist
Signed-off-by
line in the message. (more info)