Skip to content

Commit

Permalink
require location header in the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 5, 2020
1 parent c5cb1fd commit fcb4994
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Headers to attach for auth redirect. Must include "location" header
<b>Signature:</b>

```typescript
headers: ResponseHeaders;
headers: {
location: string;
} & ResponseHeaders;
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export interface AuthRedirectedParams

| Property | Type | Description |
| --- | --- | --- |
| [headers](./kibana-plugin-server.authredirectedparams.headers.md) | <code>ResponseHeaders</code> | Headers to attach for auth redirect. Must include "location" header |
| [headers](./kibana-plugin-server.authredirectedparams.headers.md) | <code>{</code><br/><code> location: string;</code><br/><code> } &amp; ResponseHeaders</code> | Headers to attach for auth redirect. Must include "location" header |

Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface AuthToolkit
| --- | --- | --- |
| [authenticated](./kibana-plugin-server.authtoolkit.authenticated.md) | <code>(data?: AuthResultParams) =&gt; AuthResult</code> | Authentication is successful with given credentials, allow request to pass through |
| [notHandled](./kibana-plugin-server.authtoolkit.nothandled.md) | <code>() =&gt; AuthResult</code> | User has no credentials. Allows user to access a resource when authRequired: 'optional' Rejects a request when authRequired: true |
| [redirected](./kibana-plugin-server.authtoolkit.redirected.md) | <code>(headers: ResponseHeaders) =&gt; AuthResult</code> | Redirect user to IdP when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional' |
| [redirected](./kibana-plugin-server.authtoolkit.redirected.md) | <code>(headers: {</code><br/><code> location: string;</code><br/><code> } &amp; ResponseHeaders) =&gt; AuthResult</code> | Redirect user to IdP when authRequired: true Allows user to access a resource without redirection when authRequired: 'optional' |

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Redirect user to IdP when authRequired: true Allows user to access a resource wi
<b>Signature:</b>

```typescript
redirected: (headers: ResponseHeaders) => AuthResult;
redirected: (headers: {
location: string;
} & ResponseHeaders) => AuthResult;
```
2 changes: 1 addition & 1 deletion src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe('Auth', () => {
const router = createRouter('/');

router.get({ path: '/', validate: false }, (context, req, res) => res.ok());
registerAuth((req, res, t) => t.redirected({}));
registerAuth((req, res, t) => t.redirected({} as any));
await server.start();

await supertest(innerServer.listener)
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/http/lifecycle/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const authResult = {
type: AuthResultType.notHandled,
};
},
redirected(headers: ResponseHeaders): AuthResult {
redirected(headers: { location: string } & ResponseHeaders): AuthResult {
return {
type: AuthResultType.redirected,
headers,
Expand Down Expand Up @@ -121,7 +121,7 @@ export interface AuthRedirectedParams {
* Headers to attach for auth redirect.
* Must include "location" header
*/
headers: ResponseHeaders;
headers: { location: string } & ResponseHeaders;
}

/**
Expand All @@ -141,7 +141,7 @@ export interface AuthToolkit {
* Redirect user to IdP when authRequired: true
* Allows user to access a resource without redirection when authRequired: 'optional'
* */
redirected: (headers: ResponseHeaders) => AuthResult;
redirected: (headers: { location: string } & ResponseHeaders) => AuthResult;
}

const toolkit: AuthToolkit = {
Expand Down
8 changes: 6 additions & 2 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ export interface AuthRedirected extends AuthRedirectedParams {

// @public
export interface AuthRedirectedParams {
headers: ResponseHeaders;
headers: {
location: string;
} & ResponseHeaders;
}

// @public (undocumented)
Expand Down Expand Up @@ -466,7 +468,9 @@ export enum AuthStatus {
export interface AuthToolkit {
authenticated: (data?: AuthResultParams) => AuthResult;
notHandled: () => AuthResult;
redirected: (headers: ResponseHeaders) => AuthResult;
redirected: (headers: {
location: string;
} & ResponseHeaders) => AuthResult;
}

// @public
Expand Down

0 comments on commit fcb4994

Please sign in to comment.