feat(sso): add provider detail endpoint DEV-2665 - #7496
Conversation
|
| # headless `auth/provider/redirect`, which the SPA posts to next. Both | ||
| # look providers up this way, so a 200 here means the redirect will work | ||
| try: | ||
| return get_socialaccount_adapter().get_app(self.request, provider_id) |
There was a problem hiding this comment.
You should call self.check_object_permissions(self.request, obj) even if it would do nothing special. Just as a safety guard if the permission classes is changed some day.
Or at least , leave a comment why you omitted. permission_classes is useless atm.
| def get(self, request, *args, **kwargs): | ||
| return super().get(request, *args, **kwargs) |
There was a problem hiding this comment.
You can probably set it at the View level. No need to overload the parent for nothing. I think we do have some examples in the code.
📣 Summary
This PR adds a public API endpoint that resolves an SSO provider's URL identifier into its display name, so the upcoming React login screens can render the "Log in with …" page that Django templates render today.
📖 Description
This PR adds GET
/api/v2/social-apps/<provider_id>/, which returns theprovider_idandnamefor a configured Social Application.Some organizations sign in through an SSO provider that is deliberately not shown on the public login page. Its Social Application has
is_publicunchecked, and they distribute a direct link to their own staff, for example:https://<kobo-server>/accounts/oidc/nca/login/. Only thencapart varies. Today, that URL renders a shared Django template titled "Log in with {{ SocialApp.name }}". The same template is used for every provider on every server.The Authentication Redesign deletes that template and rebuilds the screen in the SPA. To render it at a route like
#/login/oidc/<provider_id>, the frontend needs to turnprovider_idinto a display name and distinguish a real provider from a typo so it can show the appropriate 404. The frontend cannot read the database directly, so it needs this endpoint.Nothing changes for users yet. The existing login pages are untouched.
👀 Preview steps
Log out and open
/accounts/login/.ℹ️ Notice that "Norwegian Church Aid" is not among the SSO buttons because the provider is hidden.
Open
/accounts/oidc/nca/login/.ℹ️ Notice that the "Log in with Norwegian Church Aid" page still renders unchanged.
🔴 On main: GET
/api/v2/social-apps/nca/-> 404, because the route does not exist.🟢 On the PR: GET
/api/v2/social-apps/nca/-> 200{"provider_id": "nca", "name": "Norwegian Church Aid"}even though the provider is hidden. That's the point of the endpoint.🟢 GET
/api/v2/social-apps/typo/-> 404.🟢 GET
/api/v2/social-apps/-> 404. There is deliberately no list endpoint.🟢 Notice that the response has exactly two keys. It does not expose
client_id,secret, orserver_url.