Skip to content

Commit

Permalink
chore: Update README files according to the latest changes (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasmak authored Jun 26, 2023
1 parent 43bc4b7 commit 6bcdefa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 97 deletions.
88 changes: 5 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Vaadin SSO Kit
# SSO Kit

SSO Kit is an add-on for Vaadin Flow that provides all the configuration you need to add single sign-on capabilities to your applications.
SSO Kit is an add-on for **Vaadin Flow** and **Hilla** frameworks that provides all the configuration you need to add single sign-on capabilities to your applications.

SSO Kit is built upon the [OpenID Connect](https://openid.net/specs/openid-connect-core-1_0.html) specification and it comes with a [Spring Boot](https://spring.io/projects/spring-boot) starter module that takes care of configuring the security settings you need to authenticate against your identity provider.

Expand All @@ -12,86 +12,8 @@ These are the currently supported identity providers:

SSO Kit is compatible with [Vaadin Platform](https://vaadin.com/) starting from version [23.2.0](https://github.com/vaadin/platform/releases/tag/23.2.0).

## Getting Started

To get started with SSO Kit you just need to add the `sso-kit-starter` module as a dependency to your Vaadin application, e.g. in your `pom.xml`:

```xml
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>sso-kit-starter</artifactId>
</dependency>
```

### Setting Client Credentials and Login Route

Then you need to set your identity provider client credentials in your `application.yml`, e.g. for Keycloak:

```yaml
spring:
security:
oauth2:
client:
provider:
keycloak: # This is the registration-id, can be any value
issuer-uri: https://my-keycloak.io/realms/my-realm
registration:
keycloak: # This should be the same as the registration-id
client-id: my-client
client-secret: verySecretValue
scope:
- profile
- openid
- email
- roles
vaadin:
sso:
login-route: /oauth2/authorization/keycloak # /oauth2/authorization/<registration-id>
```
This configuration will redirect to the provider's login page any unauthorized request.
### Protecting Your Views
You can set which views require authentication annotating them as described in [Annotating the View Classes](https://vaadin.com/docs/latest/security/enabling-security/#annotating-the-view-classes). For example:
SSO Kit is compatible with [Hilla](https://hilla.dev/) starting from version [2.0.0](https://github.com/vaadin/hilla/releases/tag/2.0.0).

```java
@PermitAll
@Route(value = "private")
public class PrivateView extends VerticalLayout {
// ...
}
```

### Get the Authenticated User

The SSO Kit starter provides the `AuthenticationContext` bean that you can inject into your views to get the currently authenticated user:

```java
@PermitAll
@Route(value = "private")
public class PrivateView extends VerticalLayout {

public PrivateView(AuthenticationContext authContext) {
authContext.getAuthenticatedUser().ifPresent(user -> {
var fullName = user.getFullName();
Notification.show("Hello, " + fullName + "!");
});
}
}
```

### Logging the User Out

The same `AuthenticationContext` bean provides the `logout()` method to terminate both the local user session and the provider's session:

```java
@PermitAll
@Route(value = "private")
public class PrivateView extends VerticalLayout {
## Getting Started

public PrivateView(AuthenticationContext authContext) {
add(new Button("Logout", e -> authContext.logout()));
}
}
```
Getting started tutorials are available for [Vaadin Flow](https://vaadin.com/docs/latest/tools/sso/getting-started), for [Hilla with Lit](https://hilla.dev/docs/lit/acceleration-kits/sso-kit/getting-started) and for [Hilla with React](https://hilla.dev/docs/react/acceleration-kits/sso-kit/getting-started).
19 changes: 14 additions & 5 deletions sso-kit-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,36 @@

The **SSO Kit Client** is the client side library for the **[SSO Kit for Hilla](https://github.com/vaadin/sso-kit/tree/main/sso-kit-starter-hilla)** and depends on it.

Getting Started with the **SSO Kit for Hilla** using Lit [documentation](https://hilla.dev/docs/lit/acceleration-kits/sso-kit/getting-started/#frontend).
Getting Started with the **SSO Kit for Hilla** with Lit [documentation](https://hilla.dev/docs/lit/acceleration-kits/sso-kit/getting-started/#frontend).

Getting Started with the **SSO Kit for Hilla** using React [documentation](https://hilla.dev/docs/react/acceleration-kits/sso-kit/getting-started/#frontend).
Getting Started with the **SSO Kit for Hilla** with React [documentation](https://hilla.dev/docs/react/acceleration-kits/sso-kit/getting-started/#frontend).

The library consists three packages. The **[SSO Kit Client Lit](lit)**, **[SSO Kit Client React](react)** and **[SSO Kit Client Core](core)** which is private, so it is not published into public registry. However, its sources are included into other two libraries during building, packaging and publishing.

## Installation

Install one of the libraries for Hilla using Lit or Hilla using React:
### Install the library for Hilla with Lit:

```sh
npm i @hilla/sso-kit-client-lit
```

Once installed, you can import the `SingleSignOnContext` class in your application:

```js
import ssoContext from "@hilla/sso-kit-client-lit";
```

### Install the library for Hilla with React:

```sh
npm i @hilla/sso-kit-client-react
```

Once installed, you can import the `SingleSignOnContext` class in your application:
Once installed, you can import the `useSsoContext` hook in your application:

```js
import singleSignOnContext from "@hilla/sso-kit-client/SingleSignOnContext.js";
import { useSsoContext } from "@hilla/sso-kit-client-react";
```

## Development
Expand Down
2 changes: 1 addition & 1 deletion sso-kit-client/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build": "npm run build:transpile",
"build:transpile": "tsc -b",
"lint": "eslint **/*.ts",
"test": "karma start ../karma.config.cjs --port 9878",
"test": "karma start ../karma.config.cjs --port 9876",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
Expand Down
6 changes: 3 additions & 3 deletions sso-kit-client/lit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The **SSO Kit Client Lit** is the client side library for the **[SSO Kit for Hilla](https://github.com/vaadin/sso-kit/tree/main/sso-kit-starter-hilla)** and depends on it.

Getting Started with the **SSO Kit for Hilla** using Lit [documentation](https://hilla.dev/docs/lit/acceleration-kits/sso-kit/getting-started/#frontend).
Getting Started with the **SSO Kit for Hilla** with Lit [documentation](https://hilla.dev/docs/lit/acceleration-kits/sso-kit/getting-started/#frontend).

## Installation

Install the library for Hilla using Lit:
Install the library for Hilla with Lit:

```sh
npm i @hilla/sso-kit-client-lit
Expand All @@ -15,7 +15,7 @@ npm i @hilla/sso-kit-client-lit
Once installed, you can import the `SingleSignOnContext` class in your application:

```js
import singleSignOnContext from "@hilla/sso-kit-client-lit/SingleSignOnContext.js";
import ssoContext from "@hilla/sso-kit-client-lit";
```

## Development
Expand Down
2 changes: 1 addition & 1 deletion sso-kit-client/lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prepack": "npm run build",
"postpack": "npm run clean:build && rimraf ../core/src/*.{d.ts.map,js.map,js} ../core/src/index.d.ts ../core/src/EndpointImportError.d.ts ../core/tsconfig.tsbuildinfo",
"lint": "eslint **/*.ts",
"test": "karma start ../karma.config.cjs --port 9878",
"test": "karma start ../karma.config.cjs --port 9877",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
Expand Down
8 changes: 4 additions & 4 deletions sso-kit-client/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

The **SSO Kit Client React** is the client side library for the **[SSO Kit for Hilla](https://github.com/vaadin/sso-kit/tree/main/sso-kit-starter-hilla)** and depends on it.

Getting Started with the **SSO Kit for Hilla** using React [documentation](https://hilla.dev/docs/react/acceleration-kits/sso-kit/getting-started/#frontend).
Getting Started with the **SSO Kit for Hilla** with React [documentation](https://hilla.dev/docs/react/acceleration-kits/sso-kit/getting-started/#frontend).

## Installation

Install the library for Hilla using React:
Install the library for Hilla with React:

```sh
npm i @hilla/sso-kit-client-react
```

Once installed, you can import the `SingleSignOnContext` class in your application:
Once installed, you can import the `useSsoContext` hook in your application:

```js
import singleSignOnContext from "@hilla/sso-kit-client-react/SingleSignOnContext.js";
import { useSsoContext } from "@hilla/sso-kit-client-react";
```

## Development
Expand Down

0 comments on commit 6bcdefa

Please # to comment.