Skip to content

Commit

Permalink
Add a page for Control Center login and logout links (#3748)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
MatthewVaadin and russelljtdyer authored Oct 2, 2024
1 parent ab06427 commit 79127b6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
4 changes: 2 additions & 2 deletions articles/control-center/application-deployment/index.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Application Discovery
title: Application Deployment
description: How to use Control Center's Application Discovery feature.
order: 20
---
Expand Down Expand Up @@ -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-guidelines, Hostname Guidelines>>.
- *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>>.
- *Features*: Enable additional features like Identity Management and Localization if required.

[NOTE]
Expand Down
9 changes: 7 additions & 2 deletions articles/control-center/identity-management/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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

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]
Expand Down Expand Up @@ -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 <<login-logout#,Creating Login and Logout Links>>.

60 changes: 60 additions & 0 deletions articles/control-center/identity-management/login-logout.adoc
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 79127b6

Please sign in to comment.