Wiki source code of Front-End Authentication API

Last modified by Manuel Leduc on 2026/02/05 17:22

Show last authors
1 == Authentication Manager ==
2
3 An authentication manager provides the implementation allowing interaction with the authentication of a user backend.
4 For instance, for the XWiki backend, the authentication works by interacting with the [[OIDC Provider Extension>>extensions:Extension.OpenID Connect.OpenID Connect Provider.WebHome]].
5
6 {{code language="typescript"}}
7 /**
8 * Interface to implement for a given backend to allow users to authenticate.
9 *
10 * @since 0.11
11 */
12 interface AuthenticationManager {
13 /**
14 * Starts the authentication process.
15 * @since 0.15
16 */
17 start(): Promise<void>;
18
19 /**
20 * Handle the callback.
21 */
22 callback(): Promise<void>;
23
24 /**
25 * Returns the currently registered authorization header
26 */
27 getAuthorizationHeader(): Promise<string | undefined>;
28
29 /**
30 * @returns true of the current user is authenticated
31 */
32 isAuthenticated(): Promise<boolean>;
33
34 /**
35 * Returns the user details for the current user.
36 */
37 getUserDetails(): Promise<UserDetails>;
38
39 /**
40 * Logs out the current user.
41 */
42 logout(): Promise<void>;
43
44 /**
45 * Optional method returning the currently connected user id.
46 *
47 * @returns the id of the currently connected user, or undefined if not authenticated
48 * @since 0.20
49 */
50 getUserId?(): string | undefined;
51 }
52
53 {{/code}}
54
55 == Authentication Manager Provider ==
56
57 The authentication manager provider is responsible for resolving an authentication manager according to the current context (e.g., the current backend).
58
59 {{code language="typescript"}}
60 /**
61 * Help to resolve the right Authentication Manager based on the backend
62 * type.
63 *
64 * @since 0.11
65 */
66 interface AuthenticationManagerProvider {
67 /**
68 *
69 * @param type the identifier of the backend type
70 * @return the AuthenticationManager registered for the backend type, or undefined if none was fond
71 */
72 get(type?: string): AuthenticationManager | undefined;
73 }
74 {{/code}}
75
76 == User Details ==
77
78 {{code language="typescript"}}
79 /**
80 * Holds the user details, for now the profile link and the name of the user.
81 *
82 * @since 0.11
83 */
84 export interface UserDetails {
85 profile: string;
86 name: string;
87 }
88 {{/code}}

Get Connected