From 79127b66fc5bd64ac89f7ee2ac183caccdafb7a3 Mon Sep 17 00:00:00 2001 From: Matthew Wilson <98319962+MatthewVaadin@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:34:35 +0300 Subject: [PATCH] Add a page for Control Center login and logout links (#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> --- .../application-deployment/index.adoc | 4 +- .../identity-management/index.adoc | 9 ++- .../identity-management/login-logout.adoc | 60 +++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 articles/control-center/identity-management/login-logout.adoc diff --git a/articles/control-center/application-deployment/index.adoc b/articles/control-center/application-deployment/index.adoc index 278fa0e921..d8dc6d166f 100644 --- a/articles/control-center/application-deployment/index.adoc +++ b/articles/control-center/application-deployment/index.adoc @@ -1,5 +1,5 @@ --- -title: Application Discovery +title: Application Deployment description: How to use Control Center's Application Discovery feature. order: 20 --- @@ -82,7 +82,7 @@ In the [guibutton]*Deploy* panel on the right-hand side (as shown in the screens - *Application Name*: Give your application a meaningful name (e.g., `My App`). - *Image*: Enter the tag of the Docker image (e.g., `my-app:latest`). - *Replicas*: Specify the number of instances to run. The default is `1`. -- *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*: 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 <>. - *Features*: Enable additional features like Identity Management and Localization if required. [NOTE] diff --git a/articles/control-center/identity-management/index.adoc b/articles/control-center/identity-management/index.adoc index ba668260b0..3989ad0a62 100644 --- a/articles/control-center/identity-management/index.adoc +++ b/articles/control-center/identity-management/index.adoc @@ -15,7 +15,7 @@ With Control Center, you can do several things that allow you to centralize user - *Create & Assign Groups*: Organize users into groups, assign specific roles to the groups, and streamline permissions management. - *Manage Roles*: Define roles that can be used to control access to specific views or functionality in your application. -Before starting, make sure you've already deployed an application as described in <<../application-deployment, Deploying a Vaadin Application with Control Center>>. +Before starting, make sure you've already deployed an application as described in <<../application-deployment#,Deploying a Vaadin Application with Control Center>>. == Creating a New User @@ -23,7 +23,7 @@ Before starting, make sure you've already deployed an application as described i 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. image::../application-deployment/images/app-selector.png[App Selector] - + The dashboard provides an overview of the current user base for the selected application. image::images/app-dashboard.png[App Dashboard] @@ -74,3 +74,8 @@ Fill in the fields to create a new group: Once the group is created, the assigned users inherit the permissions associated with the roles assigned to the group. + +== Login/Logout Links + +To create login and logout links or buttons in your Vaadin application, refer to the guide on <>. + diff --git a/articles/control-center/identity-management/login-logout.adoc b/articles/control-center/identity-management/login-logout.adoc new file mode 100644 index 0000000000..ef3bae4d8d --- /dev/null +++ b/articles/control-center/identity-management/login-logout.adoc @@ -0,0 +1,60 @@ +--- +title: Login and Logout Links +description: How to create login and logout links or buttons using Control Center identity management security. +order: 40 +--- + + += Login & Logout Links + +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. + + +== Adding Login + +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: + +[source,java] +---- +public class MainLayout extends AppLayout { + + public MainLayout() { + /* <1> */ + Button loginButton = new Button("Login", event -> { + getUI().ifPresent(ui -> ui.getPage().setLocation("/oauth2/authorization/control-center")); + }); + + /* <2> */ + Anchor loginLink = new Anchor("/oauth2/authorization/control-center", "Login"); + loginLink.setRouterIgnore(true); + + addToNavbar(loginButton, loginLink); + } +} +---- + +<1> This part creates a login button. +<2> This creates a login link. You may not want to do both a button and a link, though. + + +== Adding Logout + +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: + +[source,java] +---- +public class MainLayout extends AppLayout { + + public MainLayout(@Autowired AuthenticationContext authenticationContext) { + + Button logoutButton = new Button("Logout", click -> authenticationContext.logout()); + + addToNavbar(logoutButton); + } +} +---- + + +== Deploy the Application + +Deploy the application as described in <<../application-deployment#,Deploying a Vaadin Application with Control Center>>. Be sure to activate the Identity Management feature.