# @bizdoc/okta

> BizDoc supports Okta for both authentication and authorization, in one of two configurations: server flow or client flow.

Latest version **3.2.1** (published 2025-04-08) · 0 weekly downloads

## Install

```sh
npm install @bizdoc/okta
pnpm add @bizdoc/okta
yarn add @bizdoc/okta
bun add @bizdoc/okta
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.1 |
| Published | 2025-04-08 |
| First published | 2021-09-29 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 33.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | zehavibarak |

## Links

- npm: https://www.npmjs.com/package/@bizdoc/okta
- npm.io page: https://npm.io/package/@bizdoc/okta

## Dependencies (4)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0
- [@okta/okta-angular](https://npm.io/package/@okta/okta-angular.md) ^6.5
- [@okta/okta-auth-js](https://npm.io/package/@okta/okta-auth-js.md) ^7.12
- [@okta/okta-signin-widget](https://npm.io/package/@okta/okta-signin-widget.md) ^7.30

## Recent versions

- 3.2.1 (latest) — 2025-04-08
- 3.2.0 — 2025-02-23
- 3.0.1 — 2024-09-16
- 2.2.1 — 2024-03-28
- 2.2.0 — 2024-03-10
- 2.1.3 — 2024-01-04
- 2.1.1 — 2023-09-17
- 2.0.0 — 2023-06-24
- 1.19.0 — 2023-05-10
- 1.18.0 — 2023-03-28
- 1.17.0 — 2022-10-17
- 1.16.0 — 2022-09-13
- 1.15.0 — 2022-06-06
- 1.14.2 — 2022-05-19
- 1.14.1 — 2022-05-02
- … 20 more at https://npm.io/package/@bizdoc/okta/versions

## README

# Okta for BizDoc

BizDoc supports Okta for both authentication and authorization, in one of two configurations: server flow or client flow.

Server flow redirects unauthorized users to Okta sign-in page on Okta domain, and handles the redirect.
Client flow prompts unauthorized users for credentials in an hosted widget, and negotiate with Okta on the background. 

## Setting up

1) For both modes, install BizDoc Nuget package:

```bash
dotnet add package BizDoc.Core.Okta
```

2) Add Okta application. If using server mode, choose Web Application. If using client mode, choose ODIC - OpenID Connect, and select SPA.

Okta sign-in redirect url should match "/authorization-code/callback" on server mode, and no path for client mode.

Create an API Token to allow BizDoc to retrieve users information.

3) In startup.cs, add Okta service.

For server flow, use AddOktaRedirect:

```c#
AddBizDoc(o=> {
    o.ApplicationUri = "https://app-domain";
  })
  .AddOktaServer(o=> {
    o.ApiToken = "api-token";
    o.Domain = "domain-name";
    o.ClientId = "client-id";
    o.ClientSecret = "client-secret";
  }).
    UseIdentityProvider();
  ...
UseBizDoc().
  .UseOktaServer();
```
For client mode, use AddOkta:

```c#
AddBizDoc(...)
  .AddOkta(o=> {
    o.ApiToken = "api-token";
    o.Domain = "domain-name";
  }).
    UseIdentityProvider();
```

> The UseIdentityProvider() method registers an identity provider which retrieve user information from Okta. To use a different provider, while still authenticating via Okta, see [Implementing Identity Provider](https://github.com/moding-il/bizdoc.core/issues/12).

4) Client mode only, install Angular package:

```bash
npm i @bizdoc/okta
```
Add Okta configuration in Angular app.module:

```typescript
OktaModule.forRoot({
  domain: 'domain-name',
  clientId: 'client-id'  
})
```

## Roles

In order to map user groups to BizDoc roles for authorization purposes, add a new _claim_ to Okta Authorization Server with the following specifications.

| Property | Value
| -- | --
| Name | bizdoc.roles  
| Include in token type | ID Token
| Value type | Groups
| Filter | Matches regex, .*
Include in | Any scope

#### System Role

Add an attribute to either application profile or all profiles and set its type to boolean. 
Add a claim in API server that map to the profile attribute you created.

| Property | Value
| -- | --
| Name | bizdoc.admin
| Include in token type | ID Token
| Value type | Expression
| Value | user.{attr-name-here}

---
_Source: https://npm.io/package/@bizdoc/okta · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
