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

BC-6453 - Add authorization service client module #5050

Merged
merged 47 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
913faff
BC-6453 - Add authorization service client using OpenAPI
bergatco Jun 5, 2024
a9808c1
BC-6453 - move OpenAPI generated client to `apps/server/src/infra/aut…
bergatco Jun 5, 2024
f208138
BC-6453 - move latest OpenAPI config file to separate file and use la…
bergatco Jun 5, 2024
bc66ea2
BC-6453 - add tests for `AuthorizationClientAdapter`
bergatco Jun 5, 2024
417de23
BC-6453 - remove unused OpenAPI generated models
bergatco Jun 6, 2024
eaf8756
BC-6453 - add some comments to `apps/server/src/infra/authorization-c…
bergatco Jun 6, 2024
dcdb14a
BC-6453 - extend unit tests and remove generated `AuthorizationApi` f…
bergatco Jun 7, 2024
3b9ef42
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 7, 2024
e443713
BC-6453 - fix package.json error
bergatco Jun 7, 2024
d1fc493
BC-6453 - fix `package-lock.json` issue
bergatco Jun 7, 2024
52dc411
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 7, 2024
127eb4a
BC-6453 - update API title and description for swagger to use Schulcl…
bergatco Jun 7, 2024
499febb
BC-6453 - remove redundant npm package `@openapitools/openapi-generat…
bergatco Jun 7, 2024
c8eca15
BC-6453 - revert `package-lock.json` to `main`
bergatco Jun 7, 2024
c43f99f
BC-6453 - apply renaming of `HPI Schul-Cloud` to `Schulcloud-Verbund-…
bergatco Jun 7, 2024
60fe578
BC-6453 - make barrel file `apps/server/src/infra/authorization-clien…
bergatco Jun 7, 2024
ddd78d1
BC-6453 - extract jwt from request and remove `apiKey`
bergatco Jun 10, 2024
2d400cb
BC-6453 - add unit tests for `hasPermissionByReferences`
bergatco Jun 10, 2024
be14363
BC-6453 - fix `authorization` handling
bergatco Jun 10, 2024
f119586
BC-6453 - add "own" loggable as well as extend unit tests
bergatco Jun 10, 2024
e89b3e4
BC-6453 - add unit tests for loggables
bergatco Jun 10, 2024
0ce6d86
BC-6453 - update JWT extraction and handling in AuthorizationClientAd…
bergatco Jun 10, 2024
e0db97e
BC-6453 - fix currently broken unit tests
bergatco Jun 10, 2024
7122174
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 11, 2024
7d7f51c
BC-6453 - make jwt extraction more general
bergatco Jun 11, 2024
a7453b9
BC-6453 - extend unit tests for jwt and cookie handling
bergatco Jun 11, 2024
f588019
BC-6453 - remove some more unnecessary file from generated api
bergatco Jun 11, 2024
8f1a7de
BC-6453 - remove files to be ignored
bergatco Jun 11, 2024
a18eeed
BC-6453 - add `resetAllMocks` after each unit test
bergatco Jun 11, 2024
ee2b0e8
BC-6453 - allow also ONLY jwt in authorization header
bergatco Jun 11, 2024
50317aa
BC-6453 - remove unnecessary comments, improve unit test structure pl…
bergatco Jun 11, 2024
0a0626f
BC-6453 - improve unit tests structure
bergatco Jun 11, 2024
82060cf
BC-6453 - fix wording in one unit tests
bergatco Jun 12, 2024
69d8a78
BC-6453 - further improve unit tests structure
bergatco Jun 12, 2024
2a95f62
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 12, 2024
eacdd8b
BC-6453 - rename functions
bergatco Jun 12, 2024
0d07a81
BC-6453 - move auth header creation to separate function `createOptio…
bergatco Jun 12, 2024
ca37249
BC-6453 - remove loggable tests
bergatco Jun 12, 2024
c8395e8
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 12, 2024
2574922
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 12, 2024
eeb78a5
BC-6453 - replace `UnauthorizedException` with `AuthorizationErrorLog…
bergatco Jun 13, 2024
7511741
BC-6453 - fix naming of unit test
bergatco Jun 13, 2024
1ebdf2e
BC-6453 - extend error handling in `AuthorizationErrorLoggableException`
bergatco Jun 13, 2024
e15c9bb
Merge branch 'main' into BC-6453-add-authorisation-service-client-module
bergatco Jun 13, 2024
ec9dddd
BC-6453 - extend unit tests for `AuthorizationClientAdapter` to inclu…
bergatco Jun 13, 2024
5069818
BC-6453 - re-add loggable tests
bergatco Jun 13, 2024
558bae8
BC-6453 - remove loggable tests from `AuthorizationClientAdapter` uni…
bergatco Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

bergatco marked this conversation as resolved.
Show resolved Hide resolved
# ignore some general files
.gitignore
.npmignore
git_push.sh

# ignore all files in the "models" folder
models/*

# list of allowed files in the "models" folder
!models/action.ts
!models/authorization-body-params.ts
!models/authorization-context-params.ts
!models/authorized-reponse.ts
!models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
api.ts
api/authorization-api.ts
base.ts
common.ts
configuration.ts
index.ts
models/action.ts
models/authorization-body-params.ts
models/authorization-context-params.ts
models/authorized-reponse.ts
models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
* Schulcloud-Verbund-Software Server API
* This is v3 of Schulcloud-Verbund-Software Server. Checkout /docs for v1.
*
* The version of the OpenAPI document: 3.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/



export * from './api/authorization-api';

Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/* tslint:disable */
/* eslint-disable */
/**
* Schulcloud-Verbund-Software Server API
* This is v3 of Schulcloud-Verbund-Software Server. Checkout /docs for v1.
*
* The version of the OpenAPI document: 3.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { ApiValidationError } from '../models';
// @ts-ignore
import type { AuthorizationBodyParams } from '../models';
// @ts-ignore
import type { AuthorizedReponse } from '../models';
/**
* AuthorizationApi - axios parameter creator
* @export
*/
export const AuthorizationApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary Checks if user is authorized to perform the given operation.
* @param {AuthorizationBodyParams} authorizationBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
authorizationReferenceControllerAuthorizeByReference: async (authorizationBodyParams: AuthorizationBodyParams, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'authorizationBodyParams' is not null or undefined
assertParamExists('authorizationReferenceControllerAuthorizeByReference', 'authorizationBodyParams', authorizationBodyParams)
const localVarPath = `/authorization/by-reference`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication bearer required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(authorizationBodyParams, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};

/**
* AuthorizationApi - functional programming interface
* @export
*/
export const AuthorizationApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = AuthorizationApiAxiosParamCreator(configuration)
return {
/**
*
* @summary Checks if user is authorized to perform the given operation.
* @param {AuthorizationBodyParams} authorizationBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthorizedReponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['AuthorizationApi.authorizationReferenceControllerAuthorizeByReference']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};

/**
* AuthorizationApi - factory interface
* @export
*/
export const AuthorizationApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = AuthorizationApiFp(configuration)
return {
/**
*
* @summary Checks if user is authorized to perform the given operation.
* @param {AuthorizationBodyParams} authorizationBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: any): AxiosPromise<AuthorizedReponse> {
return localVarFp.authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options).then((request) => request(axios, basePath));
},
};
};

/**
* AuthorizationApi - interface
* @export
* @interface AuthorizationApi
*/
export interface AuthorizationApiInterface {
/**
*
* @summary Checks if user is authorized to perform the given operation.
* @param {AuthorizationBodyParams} authorizationBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthorizationApiInterface
*/
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): AxiosPromise<AuthorizedReponse>;

}

/**
* AuthorizationApi - object-oriented interface
* @export
* @class AuthorizationApi
* @extends {BaseAPI}
*/
export class AuthorizationApi extends BaseAPI implements AuthorizationApiInterface {
/**
*
* @summary Checks if user is authorized to perform the given operation.
* @param {AuthorizationBodyParams} authorizationBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthorizationApi
*/
public authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig) {
return AuthorizationApiFp(this.configuration).authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options).then((request) => request(this.axios, this.basePath));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* tslint:disable */
/* eslint-disable */
/**
* Schulcloud-Verbund-Software Server API
* This is v3 of Schulcloud-Verbund-Software Server. Checkout /docs for v1.
*
* The version of the OpenAPI document: 3.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';

export const BASE_PATH = "http://localhost:3030/api/v3".replace(/\/+$/, "");

/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};

/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}

/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;

constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};

/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}

interface ServerMap {
[key: string]: {
url: string,
description: string,
}[];
}

/**
*
* @export
*/
export const operationServerMap: ServerMap = {
}
Loading
Loading