Skip to content

Commit b334485

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
AdminForth/1703/make-s3-adapter-support-url-pa AdminForth/1703/make-s3-adapter-support-url-pa
2 parents 96755c1 + 8c94100 commit b334485

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

adminforth/documentation/docs/tutorial/09-Plugins/11-oauth.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,21 @@ Links to adapters:
535535
[Keycloak](https://github.com/devforth/adminforth-oauth-adapter-keycloak)
536536

537537

538+
## Starting OAuth flow from an external page
539+
540+
If you have an external website with a "Sign in" button that should open the AdminForth OAuth flow directly — without showing the login form first — use the `start_oauth` query parameter:
541+
542+
```
543+
https://your-admin.example.com/login?start_oauth=google
544+
https://your-admin.example.com/login?start_oauth=clerk
545+
```
546+
547+
The value must match the provider name (case-insensitive). AdminForth will immediately redirect the user to the OAuth provider, skipping the login page entirely.
548+
549+
The provider name is derived from the adapter class name — for example `AdminForthAdapterOauth2Google``google`, `AdminForthAdapterOauth2Clerk``clerk`.
550+
551+
If the specified provider is not found, an error toast is shown on the login page. If `start_oauth` is provided without a value (`?start_oauth`), nothing happens and the regular login form is displayed.
552+
538553
## Fill user full name
539554

540555
If you have a fullName field in your users resource, you can add it to the plugin setup:

adminforth/spa/src/utils/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const LS_LANG_KEY = `afLanguage`;
2121
const MAX_CONSECUTIVE_EMPTY_RESULTS = 2;
2222
const ITEMS_PER_PAGE_LIMIT = 100;
2323
const AUTOLOGIN_QUERY_PARAM = 'autologin';
24+
const START_OAUTH_QUERY_PARAM = 'start_oauth';
2425

2526
export function getAutologinCredentials(autologin: unknown): { username: string, password: string } | null {
2627
if (typeof autologin !== 'string') {
@@ -117,6 +118,12 @@ export async function redirectToLogin() {
117118
if (currentPath !== '/login' && currentPath !== homePagePath) {
118119
query.next = next;
119120
}
121+
122+
const currentQuery = router.currentRoute.value.query;
123+
124+
if (START_OAUTH_QUERY_PARAM in currentQuery) {
125+
query[START_OAUTH_QUERY_PARAM] = (currentQuery[START_OAUTH_QUERY_PARAM] as string) ?? '';
126+
}
120127

121128
await router.push({ name: 'login', query });
122129
}

0 commit comments

Comments
 (0)