README.md 1.17 KB
Newer Older
1
# SIB OIDC
Nicolas Mérigot's avatar
Nicolas Mérigot committed
2
Allows your users to login via a given OIDC provider.
3
## Installation
Nicolas Mérigot's avatar
Nicolas Mérigot committed
4
Add the following within the `<head>` of your HTML:
5
```html
Nicolas Mérigot's avatar
Nicolas Mérigot committed
6 7 8 9 10 11 12 13 14 15
  <script type="module" src="https://unpkg.com/@startinblox/oidc@latest"></script>
  <sib-auth>
    <sib-auth-provider
    class="sib-auth-provider"
    data-authority="https://test-paris.happy-dev.fr/openid/"
    data-client_id="833925"
    data-id="paris"
    >
    </sib-auth-provider>
  </sib-auth>
16 17
```

Alexandre's avatar
Alexandre committed
18 19 20
## Documentation
### bind-user
To associate the currently logged in user to a component, add the `bind-user` attribute to it.
Nicolas Mérigot's avatar
Nicolas Mérigot committed
21
It will set its `data-src' attribute to the currently logged in user's resource URL.
Clément's avatar
Clément committed
22

Alexandre's avatar
Alexandre committed
23 24 25 26 27 28 29 30
**Example:**
```html
<sib-conversation bind-user></sib-conversation>
```
will result in :
```html
<sib-conversation data-src="https://your-domain/your-user-uri/3" bind-user></sib-conversation>
```
Nicolas Mérigot's avatar
Nicolas Mérigot committed
31
### Methods available
Alexandre's avatar
Alexandre committed
32

Nicolas Mérigot's avatar
Nicolas Mérigot committed
33 34 35 36 37 38 39 40 41 42 43 44
#### Login
```
document.querySelector('sib-auth').login();
```
#### Logout
```
document.querySelector('sib-auth').logout();
```
#### Get user info
```
document.querySelector('sib-auth').getUser();
```
Alexandre's avatar
Alexandre committed
45

Alexandre's avatar
Alexandre committed
46
### Configuration
47
See [the available properties here](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager)