Skip to content

Commit 79127b6

Browse files
Add a page for Control Center login and logout links (vaadin#3748)
* Add a page for Control Center login and logout links * Add router ignore to link * First pass at editing. * Second pass at editing and formatting. --------- Co-authored-by: Russell J.T. Dyer <6652767+russelljtdyer@users.noreply.github.com>
1 parent ab06427 commit 79127b6

File tree

3 files changed

+69
-4
lines changed

3 files changed

+69
-4
lines changed

articles/control-center/application-deployment/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Application Discovery
2+
title: Application Deployment
33
description: How to use Control Center's Application Discovery feature.
44
order: 20
55
---
@@ -82,7 +82,7 @@ In the [guibutton]*Deploy* panel on the right-hand side (as shown in the screens
8282
- *Application Name*: Give your application a meaningful name (e.g., `My App`).
8383
- *Image*: Enter the tag of the Docker image (e.g., `my-app:latest`).
8484
- *Replicas*: Specify the number of instances to run. The default is `1`.
85-
- *Hostname*: Set the external URL to access your application (e.g., `https://app.example.com`). For more information on how to choose a proper hostname, refer to the <<hostname-guidelines, Hostname Guidelines>>.
85+
- *Hostname*: Set the external URL to access your application (e.g., `https://app.example.com`). For more information on how to choose a proper hostname, refer to the <<hostname-guidelines#, Hostname Guidelines>>.
8686
- *Features*: Enable additional features like Identity Management and Localization if required.
8787

8888
[NOTE]

articles/control-center/identity-management/index.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ With Control Center, you can do several things that allow you to centralize user
1515
- *Create & Assign Groups*: Organize users into groups, assign specific roles to the groups, and streamline permissions management.
1616
- *Manage Roles*: Define roles that can be used to control access to specific views or functionality in your application.
1717

18-
Before starting, make sure you've already deployed an application as described in <<../application-deployment, Deploying a Vaadin Application with Control Center>>.
18+
Before starting, make sure you've already deployed an application as described in <<../application-deployment#,Deploying a Vaadin Application with Control Center>>.
1919

2020

2121
== Creating a New User
2222

2323
To create a new user, first select the relevant application from the [guilabel]*Application Selector*, as shown in the screenshot here. It'll display the application's dashboard.
2424

2525
image::../application-deployment/images/app-selector.png[App Selector]
26-
26+
2727
The dashboard provides an overview of the current user base for the selected application.
2828

2929
image::images/app-dashboard.png[App Dashboard]
@@ -74,3 +74,8 @@ Fill in the fields to create a new group:
7474

7575
Once the group is created, the assigned users inherit the permissions associated with the roles assigned to the group.
7676

77+
78+
== Login/Logout Links
79+
80+
To create login and logout links or buttons in your Vaadin application, refer to the guide on <<login-logout#,Creating Login and Logout Links>>.
81+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Login and Logout Links
3+
description: How to create login and logout links or buttons using Control Center identity management security.
4+
order: 40
5+
---
6+
7+
8+
= Login & Logout Links
9+
10+
For users to login and logout, it can be useful to provide them with a link or button. This page explains how to do that in a Vaadin application when using the <<../identity-management#,Identity Management feature>> in Control Center.
11+
12+
13+
== Adding Login
14+
15+
To add a login link or button to a Vaadin application, you'll need to create a component that redirects users to the login page provided by Control Center -- for when they click on the link or button. Here's an example of how you might do that:
16+
17+
[source,java]
18+
----
19+
public class MainLayout extends AppLayout {
20+
21+
public MainLayout() {
22+
/* <1> */
23+
Button loginButton = new Button("Login", event -> {
24+
getUI().ifPresent(ui -> ui.getPage().setLocation("/oauth2/authorization/control-center"));
25+
});
26+
27+
/* <2> */
28+
Anchor loginLink = new Anchor("/oauth2/authorization/control-center", "Login");
29+
loginLink.setRouterIgnore(true);
30+
31+
addToNavbar(loginButton, loginLink);
32+
}
33+
}
34+
----
35+
36+
<1> This part creates a login button.
37+
<2> This creates a login link. You may not want to do both a button and a link, though.
38+
39+
40+
== Adding Logout
41+
42+
To add a logout link or button to a Vaadin application, you'll need to create a component that triggers the logout process. Here's an example of how to create a button, only:
43+
44+
[source,java]
45+
----
46+
public class MainLayout extends AppLayout {
47+
48+
public MainLayout(@Autowired AuthenticationContext authenticationContext) {
49+
50+
Button logoutButton = new Button("Logout", click -> authenticationContext.logout());
51+
52+
addToNavbar(logoutButton);
53+
}
54+
}
55+
----
56+
57+
58+
== Deploy the Application
59+
60+
Deploy the application as described in <<../application-deployment#,Deploying a Vaadin Application with Control Center>>. Be sure to activate the Identity Management feature.

0 commit comments

Comments
 (0)