Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a redirect flow for end_session endpoint handling #198

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,33 @@ this.tokenHandler.performTokenRequest(this.configuration, request)
});
```

##### Make End Session Requests

```typescript
this.notifier = new AuthorizationNotifier();
// uses a redirect flow
this.authorizationHandler = new RedirectRequestHandler();
// set notifier to deliver responses
this.authorizationHandler.setAuthorizationNotifier(this.notifier);
// set a listener to listen for authorization responses
this.notifier.setAuthorizationListener((request, response, error) => {
log('End Session request complete ', request, response, error);
if (response && response instanceof EndSessionResponse) {
//do clean up
}
});

// create a request
const request = new EndSessionRequest({
id_token_hint: idToken,
post_logout_redirect_uri: post_logout_redirect_uri,
state: undefined,
})

// make the end Session request
this.authorizationHandler.performEndSessionRequest(this.configuration, request);
```

### Development

#### Preamble
Expand Down
6 changes: 6 additions & 0 deletions built/authorization_management_request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { StringMap } from './types';
export declare abstract class AuthorizationManagementRequest {
abstract state: string;
abstract toJson(): Promise<object>;
abstract toRequestMap(): StringMap;
}
23 changes: 23 additions & 0 deletions built/authorization_management_request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions built/authorization_management_response.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Represents the AuthorizationError as a JSON object.
*/
export interface AuthorizationErrorJson {
error: string;
error_description?: string;
error_uri?: string;
state?: string;
}
export declare abstract class AuthorizationManagementResponse {
abstract state: string;
abstract toJson(): object;
}
/**
* Represents the Authorization error response.
* For more information look at:
* https://tools.ietf.org/html/rfc6749#section-4.1.2.1
*/
export declare class AuthorizationError {
error: string;
errorDescription?: string;
errorUri?: string;
state?: string;
constructor(error: AuthorizationErrorJson);
toJson(): AuthorizationErrorJson;
}
46 changes: 46 additions & 0 deletions built/authorization_management_response.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion built/authorization_request.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AuthorizationManagementRequest } from './authorization_management_request';
import { Crypto } from './crypto_utils';
import { StringMap } from './types';
export declare const BUILT_IN_PARAMETERS: string[];
/**
* Represents an AuthorizationRequest as JSON.
*/
Expand All @@ -17,7 +19,7 @@ export interface AuthorizationRequestJson {
* For more information look at
* https://tools.ietf.org/html/rfc6749#section-4.1.1
*/
export declare class AuthorizationRequest {
export declare class AuthorizationRequest extends AuthorizationManagementRequest {
private crypto;
private usePkce;
static RESPONSE_TYPE_TOKEN: string;
Expand All @@ -40,4 +42,5 @@ export declare class AuthorizationRequest {
* Serializes the AuthorizationRequest to a JavaScript Object.
*/
toJson(): Promise<AuthorizationRequestJson>;
toRequestMap(): StringMap;
}
Loading