You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sdk/js): add OIDC auth support for TypeScript SDK (#1219)
* feat(sdk/js): add oauth authentication type
Signed-off-by: Árpád Csepi <csepi.arpad@outlook.com>
* fix(sdk/ts): use milliseconds in cached token timestamps
Signed-off-by: Árpád Csepi <csepi.arpad@outlook.com>
---------
Signed-off-by: Árpád Csepi <csepi.arpad@outlook.com>
The SDK supports OIDC/OAuth for Directory bearer authentication on gRPC:
111
+
112
+
- Interactive login via Authorization Code + PKCE with a loopback callback (`authenticateOAuthPkce()`)
113
+
- Pre-issued access token via `DIRECTORY_CLIENT_AUTH_TOKEN`
114
+
115
+
Interactive PKCE sessions are cached alongside other Directory tooling at `$XDG_CONFIG_HOME/dirctl/auth-token.json` or `~/.config/dirctl/auth-token.json`. Pre-issued tokens from configuration are used directly and are not written to the cache by the constructor.
116
+
117
+
Use this mode when your deployment expects a **Bearer access token** on gRPC (for example via a gateway that validates OIDC tokens). Register your IdP application with a **redirect URI** that matches `DIRECTORY_CLIENT_OIDC_REDIRECT_URI` exactly (for example `http://localhost:8484/callback`). The SDK starts a short-lived HTTP server on loopback to receive the authorization redirect.
118
+
119
+
Some IdPs use **public clients** with PKCE; your IdP may still expect a `client_secret` field in configuration. In that case, use a **random placeholder** from environment variables, not a real secret in source code.
120
+
121
+
**Important:** The default in-repo Envoy authorization stack validates **GitHub** tokens. OIDC access tokens from your IdP only work if your environment’s gateway or auth service is configured to accept them.
// After exporting the variables above (or building a Config with authMode: 'oidc'):
139
+
constclient=newClient();
140
+
awaitclient.authenticateOAuthPkce();
141
+
```
142
+
143
+
For custom transports, call `Client.createGRPCTransport(oidcConfig, { oidcTokenHolder })` with an `OAuthTokenHolder` (exported from this package). The usual path is `new Client(oidcConfig)`, which wires the holder and transport automatically.
0 commit comments