Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arkitektio/herre-ts

Oauth2 based Authentication Flows for React
https://github.com/arkitektio/herre-ts

arkitekt arkitekt-client typescript

Last synced: 17 days ago
JSON representation

Oauth2 based Authentication Flows for React

Awesome Lists containing this project

README

        

# herre-ts

Herre is a typescript libary for authenticating users via the Oauth2 Protocol and OpenID Connect.
Contrary to other libaries, this library focusses on purely client side authentication. Meaning
that all authentication is done in the browser. This is done via the PKCE extension of the Oauth2
"authorization code" flow.

## Installation

```bash
yarn add @jhnnsrs/herre
```

## Features

- [x] PKCE
- [x] Refresh tokens
- [x] User info endpoint inspection
- [ ] Silent refresh

## Usage

```typescript
import { Route, BrowserRouter as Router, Routes } from "react-router-dom";
import { useHerre, Callback, HerreProvider } from "@jhnnsrs/herre";

export const Test = () => {
const { login, logout, token, refresh } = useHerre();

return (
<>
login({
grant: {
clientId: "test",
redirectUri: window.location.origin + "/callback",
scopes: ["openid", "profile", "email"],
clientSecret: "can be empty",
},
endpoint: {
base_url: "http://localhost:8010/o", //base url of the authorization server
tokenUrl: "http://localhost:8010/o/token", // if not provided, will be inferred
}
})}>Login

Only visible when logged in

>
);
};

function App() {

return (



// Other router libraries can be used

} />
} /> //Default callback component




);
}

export default App;
```