Skip to content

Commit

Permalink
make sure provider attribute is set also in case of ldap authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Feb 17, 2024
1 parent 1cc2bdb commit 6b08a54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
9 changes: 0 additions & 9 deletions ui/src/App.test.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions ui/src/components/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ import Button from "./button";
import Input from "./input";
import Error from './error';
import { ClickEvent } from './types';
import { get_runtime_config } from "../../runtime_config";
import { RuntimeConfig } from '../../types';


const authenticate = async (username: string, password: string) => {
const params = new URLSearchParams();
let config: RuntimeConfig | undefined = get_runtime_config();

params.append('username', username);
params.append('password', password);
params.append('grant_type', 'password');

if (config) {
params.append('provider', config.login_provider);
} else {
console.log('RuntimeConfig is undefined')
}

let response = await fetch(
'/api/token',
{
Expand Down
12 changes: 11 additions & 1 deletion ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type TResponseTypeBasedProps<T> =


export type ProviderType = 'google' | 'github';

export type LoginProvider = 'db' | 'ldap'

export type TOauth2Props<T = TAuthTokenPayload> = {
provider: ProviderType;
Expand All @@ -38,6 +38,16 @@ export type RuntimeConfig = {
google: OAuth2ProviderType,
github: OAuth2ProviderType
}
/*
There are two types of buttons to sign in:
1. social - or OIDC/OAuth2
2. default login button
When signing in via Social/OIDC/OAuth2 provider attributes is set the OIDC provider
When signing in via default login button - backend can authenticate via
DB or via LDAP. `login_provider` attribute is there to distinguish between
DB or LDAP authentication.
*/
login_provider: LoginProvider
}

declare global {
Expand Down

0 comments on commit 6b08a54

Please sign in to comment.