@openmfp/portal-server-lib 0.0.0 → 0.162.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +119 -0
- package/dist/auth/auth-config.service.d.ts +25 -0
- package/dist/auth/auth-config.service.js +125 -0
- package/dist/auth/auth-config.service.js.map +1 -0
- package/dist/auth/auth-token.service.d.ts +22 -0
- package/dist/auth/auth-token.service.js +79 -0
- package/dist/auth/auth-token.service.js.map +1 -0
- package/dist/auth/auth.callback.d.ts +10 -0
- package/dist/auth/auth.callback.js +20 -0
- package/dist/auth/auth.callback.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +18 -0
- package/dist/auth/auth.controller.js +117 -0
- package/dist/auth/auth.controller.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/redirect-uri.d.ts +2 -0
- package/dist/auth/redirect-uri.js +24 -0
- package/dist/auth/redirect-uri.js.map +1 -0
- package/dist/config/config.controller.d.ts +25 -0
- package/dist/config/config.controller.js +135 -0
- package/dist/config/config.controller.js.map +1 -0
- package/dist/config/context/entity-context-provider.d.ts +17 -0
- package/dist/config/context/entity-context-provider.js +20 -0
- package/dist/config/context/entity-context-provider.js.map +1 -0
- package/dist/config/context/feature-toggles-provider.d.ts +9 -0
- package/dist/config/context/feature-toggles-provider.js +26 -0
- package/dist/config/context/feature-toggles-provider.js.map +1 -0
- package/dist/config/context/index.d.ts +3 -0
- package/dist/config/context/index.js +4 -0
- package/dist/config/context/index.js.map +1 -0
- package/dist/config/context/portal-context-provider.d.ts +12 -0
- package/dist/config/context/portal-context-provider.js +59 -0
- package/dist/config/context/portal-context-provider.js.map +1 -0
- package/dist/config/context/request-context-provider.d.ts +7 -0
- package/dist/config/context/request-context-provider.js +17 -0
- package/dist/config/context/request-context-provider.js.map +1 -0
- package/dist/config/context/service-provider.d.ts +27 -0
- package/dist/config/context/service-provider.js +8 -0
- package/dist/config/context/service-provider.js.map +1 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +15 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/luigi/luigi-config-nodes/luigi-config-nodes.service.d.ts +10 -0
- package/dist/config/luigi/luigi-config-nodes/luigi-config-nodes.service.js +55 -0
- package/dist/config/luigi/luigi-config-nodes/luigi-config-nodes.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/config-transfer-node.service.d.ts +9 -0
- package/dist/config/luigi/luigi-data/config-transfer-node.service.js +53 -0
- package/dist/config/luigi/luigi-data/config-transfer-node.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/content-configuration-luigi-data.service.d.ts +16 -0
- package/dist/config/luigi/luigi-data/content-configuration-luigi-data.service.js +123 -0
- package/dist/config/luigi/luigi-data/content-configuration-luigi-data.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/content-configuration-validator.service.d.ts +12 -0
- package/dist/config/luigi/luigi-data/content-configuration-validator.service.js +59 -0
- package/dist/config/luigi/luigi-data/content-configuration-validator.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/intent-resolve.service.d.ts +6 -0
- package/dist/config/luigi/luigi-data/intent-resolve.service.js +78 -0
- package/dist/config/luigi/luigi-data/intent-resolve.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/luigi-data.service.d.ts +5 -0
- package/dist/config/luigi/luigi-data/luigi-data.service.js +2 -0
- package/dist/config/luigi/luigi-data/luigi-data.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/node-extended-data.service.d.ts +5 -0
- package/dist/config/luigi/luigi-data/node-extended-data.service.js +30 -0
- package/dist/config/luigi/luigi-data/node-extended-data.service.js.map +1 -0
- package/dist/config/luigi/luigi-data/texts-translate.service.d.ts +5 -0
- package/dist/config/luigi/luigi-data/texts-translate.service.js +37 -0
- package/dist/config/luigi/luigi-data/texts-translate.service.js.map +1 -0
- package/dist/config/model/breadcrumb-badge.d.ts +6 -0
- package/dist/config/model/breadcrumb-badge.js +2 -0
- package/dist/config/model/breadcrumb-badge.js.map +1 -0
- package/dist/config/model/content-configuration-validation.d.ts +17 -0
- package/dist/config/model/content-configuration-validation.js +6 -0
- package/dist/config/model/content-configuration-validation.js.map +1 -0
- package/dist/config/model/content-configuration.d.ts +41 -0
- package/dist/config/model/content-configuration.js +2 -0
- package/dist/config/model/content-configuration.js.map +1 -0
- package/dist/config/model/entity.d.ts +3 -0
- package/dist/config/model/entity.js +19 -0
- package/dist/config/model/entity.js.map +1 -0
- package/dist/config/model/luigi-user-settings.d.ts +18 -0
- package/dist/config/model/luigi-user-settings.js +2 -0
- package/dist/config/model/luigi-user-settings.js.map +1 -0
- package/dist/config/model/luigi.node.d.ts +157 -0
- package/dist/config/model/luigi.node.js +2 -0
- package/dist/config/model/luigi.node.js.map +1 -0
- package/dist/env/discovery.service.d.ts +14 -0
- package/dist/env/discovery.service.js +43 -0
- package/dist/env/discovery.service.js.map +1 -0
- package/dist/env/env-variables.service.d.ts +20 -0
- package/dist/env/env-variables.service.js +47 -0
- package/dist/env/env-variables.service.js.map +1 -0
- package/dist/env/env.controller.d.ts +7 -0
- package/dist/env/env.controller.js +38 -0
- package/dist/env/env.controller.js.map +1 -0
- package/dist/env/env.service.d.ts +18 -0
- package/dist/env/env.service.js +45 -0
- package/dist/env/env.service.js.map +1 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.js +5 -0
- package/dist/env/index.js.map +1 -0
- package/dist/health/health-checker.d.ts +6 -0
- package/dist/health/health-checker.js +6 -0
- package/dist/health/health-checker.js.map +1 -0
- package/dist/health/health.controller.d.ts +16 -0
- package/dist/health/health.controller.js +77 -0
- package/dist/health/health.controller.js.map +1 -0
- package/dist/health/index.d.ts +2 -0
- package/dist/health/index.js +3 -0
- package/dist/health/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/injection-tokens.d.ts +11 -0
- package/dist/injection-tokens.js +12 -0
- package/dist/injection-tokens.js.map +1 -0
- package/dist/local-nodes/index.d.ts +1 -0
- package/dist/local-nodes/index.js +2 -0
- package/dist/local-nodes/index.js.map +1 -0
- package/dist/local-nodes/local-nodes.controller.d.ts +19 -0
- package/dist/local-nodes/local-nodes.controller.js +77 -0
- package/dist/local-nodes/local-nodes.controller.js.map +1 -0
- package/dist/logout/index.d.ts +3 -0
- package/dist/logout/index.js +3 -0
- package/dist/logout/index.js.map +1 -0
- package/dist/logout/logout-callback.d.ts +4 -0
- package/dist/logout/logout-callback.js +2 -0
- package/dist/logout/logout-callback.js.map +1 -0
- package/dist/logout/logout.controller.d.ts +11 -0
- package/dist/logout/logout.controller.js +52 -0
- package/dist/logout/logout.controller.js.map +1 -0
- package/dist/logout/noop-logout.service.d.ts +5 -0
- package/dist/logout/noop-logout.service.js +17 -0
- package/dist/logout/noop-logout.service.js.map +1 -0
- package/dist/portal.module.d.ts +25 -0
- package/dist/portal.module.js +124 -0
- package/dist/portal.module.js.map +1 -0
- package/dist/services/cookies.service.d.ts +8 -0
- package/dist/services/cookies.service.js +33 -0
- package/dist/services/cookies.service.js.map +1 -0
- package/dist/services/guards/request-code-param.guard.d.ts +4 -0
- package/dist/services/guards/request-code-param.guard.js +25 -0
- package/dist/services/guards/request-code-param.guard.js.map +1 -0
- package/dist/services/header-parser.service.d.ts +4 -0
- package/dist/services/header-parser.service.js +22 -0
- package/dist/services/header-parser.service.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +4 -0
- package/dist/services/index.js.map +1 -0
- package/package.json +79 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Portal server library
|
|
2
|
+
|
|
3
|
+
This library helps you to set up an openmfp based micro frontend portal server with ease.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
[](https://api.reuse.software/info/github.com/openmfp/portal-server-lib)
|
|
7
|
+
|
|
8
|
+
This library helps you to set up a [Nest.js](https://nestjs.com/) server to serve a dynamic luigi configuration.
|
|
9
|
+
It is closely related to the [portal ui library](https://github.com/openmfp/portal-ui-lib).
|
|
10
|
+
|
|
11
|
+
The main features of this library are:
|
|
12
|
+
|
|
13
|
+
- Provide a Dynamic Luigi configuration without the need to deploy a library
|
|
14
|
+
- Authentication capabilities with GitHub and Auth Server
|
|
15
|
+
- Dynamic development capabilities - Embed your local MicroFrontend into a running luigi frame.
|
|
16
|
+
|
|
17
|
+
# Getting started
|
|
18
|
+
|
|
19
|
+
## Set up an environment
|
|
20
|
+
|
|
21
|
+
To be able to use the library, the following environment properties have to be provided:
|
|
22
|
+
|
|
23
|
+
- **Mandatory**
|
|
24
|
+
|
|
25
|
+
| Property name | Description |
|
|
26
|
+
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| IDP_NAMES | Comma separated values of the name(s) of the Identity Providers (IDPs) used for authentication. |
|
|
28
|
+
| BASE*DOMAINS*${idp} | Comma separated values of base domains for the application. |
|
|
29
|
+
| AUTH*SERVER_URL*${idp} | The URL for the authentication service provider specific to the idp name. This URL is used for retrieveing an authenticating a user. |
|
|
30
|
+
| TOKEN*URL*${idp} | The URL for the authentication token service provider specific to the idp name. This URL is used for retrieveing an auth tokens. |
|
|
31
|
+
| OIDC*CLIENT_ID*${idp} | Client ID for the OpenID Connect (OIDC) configuration. The Client ID is used to identify the application to the OIDC provider (e.g., an authorization server). |
|
|
32
|
+
| OIDC*CLIENT_SECRET*${idp} | Client Secret for the OIDC configuration. The Client Secret is a confidential value known only to the application and the OIDC provider, used to authenticate the application to the provider. |
|
|
33
|
+
| CONTENT_CONFIGURATION_VALIDATOR_API_URL | Endpoint URL for custom content configuration validation. Endpoint returns useful error message when configuration is invalid. |
|
|
34
|
+
|
|
35
|
+
- **Optional**
|
|
36
|
+
|
|
37
|
+
| Property name | Description |
|
|
38
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| HEALTH_CHECK_INTERVAL | The interval in _milliseconds_ at which the application performs health checks to ensure its components are functioning correctly. Default 2000 ms. |
|
|
40
|
+
| LOGOUT_REDIRECT_URL | The url to redirect user after logout action, by default _/logout_. |
|
|
41
|
+
| ENVIRONMENT | This property indicates the environment in which the application is running, _local_ indicates development environment. |
|
|
42
|
+
| DEVELOPMENT_INSTANCE | This property indicates if the portal runs in development mode. |
|
|
43
|
+
| FRONTEND_PORT | Set the port number on which the frontend of the application will run. |
|
|
44
|
+
| VALID_WEBCOMPONENT_URLS | To enable CORS Web component Loading: basically you need to add external domains where the Web Components are hosted; `".?"` in this examle, we are sepcify that we can load Web Components from everyhere. |
|
|
45
|
+
| FEATURE_TOGGLES | Comma separated values of features following the convention `featureName=boolean`. Boolean value indicates is the feature is on/off (true/false) |
|
|
46
|
+
|
|
47
|
+
Below is an example of a `.env` file for configuring the application:
|
|
48
|
+
|
|
49
|
+
```properties
|
|
50
|
+
## Mandatory
|
|
51
|
+
CONTENT_CONFIGURATION_VALIDATOR_API_URL=https://example.com/validate
|
|
52
|
+
IDP_NAMES=app,dev
|
|
53
|
+
BASE_DOMAINS_APP=localhost,example.com
|
|
54
|
+
AUTH_SERVER_URL_APP=https://example.com/auth
|
|
55
|
+
TOKEN_URL_APP=https://example.com/token
|
|
56
|
+
OIDC_CLIENT_ID_APP=app_client_id
|
|
57
|
+
OIDC_CLIENT_SECRET_APP= app_client_secret
|
|
58
|
+
|
|
59
|
+
## Portal
|
|
60
|
+
OPENMFP_PORTAL_CONTEXT_CRD_GATEWAY_API_URL=https://example.com/graphql
|
|
61
|
+
|
|
62
|
+
## Optional
|
|
63
|
+
DEVELOPMENT_INSTANCE=true
|
|
64
|
+
ENVIRONMENT='local'
|
|
65
|
+
VALID_WEBCOMPONENT_URLS=".?"
|
|
66
|
+
FEATURE_TOGGLES="foo=true,boo=false"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Consuming the library
|
|
70
|
+
|
|
71
|
+
This library exposes a Nest module as an api and needs a main project to run.
|
|
72
|
+
|
|
73
|
+
All system environment variables set and prefixed with `OPENMFP_PORTAL_CONTEXT_` are automatically read and accessible at the `/rest/config` endpoint.
|
|
74
|
+
For example, `OPENMFP_PORTAL_CONTEXT_CRD_GATEWAY_API_URL=https://example.com/graphql` transforms
|
|
75
|
+
to `"portalContext": {"crdGatewayApiUrl": "https://example.com/graphql"}`, with the whole resulting response:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"portalContext": { "crdGatewayApiUrl": "https://example.com/graphql" },
|
|
80
|
+
"featureToggles": { "foo": true },
|
|
81
|
+
"providers": []
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Import the module
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { NestFactory } from '@nestjs/core';
|
|
89
|
+
import { PortalModule } from '@portal/server-lib';
|
|
90
|
+
|
|
91
|
+
async function bootstrap() {
|
|
92
|
+
const app = await NestFactory.create(
|
|
93
|
+
PortalModule.create({
|
|
94
|
+
healthChecker: OpenHealthChecker,
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
await app.listen(process.env.PORT || 3000);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// bootstrap the app
|
|
101
|
+
bootstrap();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Requirements
|
|
105
|
+
|
|
106
|
+
The portal requires an installation of node.js and npm.
|
|
107
|
+
Check out the [package.json](package.json) for the required node version and dependencies.
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file in this repository for instructions on how to contribute to openMFP.
|
|
112
|
+
|
|
113
|
+
## Code of Conduct
|
|
114
|
+
|
|
115
|
+
Please refer to the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file in this repository for information on the expected Code of Conduct for contributing to openMFP.
|
|
116
|
+
|
|
117
|
+
## Licensing
|
|
118
|
+
|
|
119
|
+
Copyright 2025 SAP SE or an SAP affiliate company and openMFP contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/openmfp/portal-server-lib).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DiscoveryService, EnvService } from '../env/index.js';
|
|
2
|
+
import type { Request } from 'express';
|
|
3
|
+
export interface ServerAuthVariables {
|
|
4
|
+
idpName: string;
|
|
5
|
+
baseDomain: string;
|
|
6
|
+
oauthServerUrl: string;
|
|
7
|
+
oauthTokenUrl: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
clientSecret: string;
|
|
10
|
+
oidcIssuerUrl: string;
|
|
11
|
+
endSessionUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthConfigService {
|
|
14
|
+
getAuthConfig(request: Request): Promise<ServerAuthVariables>;
|
|
15
|
+
}
|
|
16
|
+
export declare class EnvAuthConfigService implements AuthConfigService {
|
|
17
|
+
private envService;
|
|
18
|
+
private discoveryService;
|
|
19
|
+
constructor(envService: EnvService, discoveryService: DiscoveryService);
|
|
20
|
+
getAuthConfig(request: Request): Promise<ServerAuthVariables>;
|
|
21
|
+
private getAuthEnv;
|
|
22
|
+
private getBaseDomainsToIdp;
|
|
23
|
+
private formatIdpNameForEnvVar;
|
|
24
|
+
private getBaseDomainRegex;
|
|
25
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { DiscoveryService, EnvService } from '../env/index.js';
|
|
11
|
+
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
let EnvAuthConfigService = class EnvAuthConfigService {
|
|
14
|
+
envService;
|
|
15
|
+
discoveryService;
|
|
16
|
+
constructor(envService, discoveryService) {
|
|
17
|
+
this.envService = envService;
|
|
18
|
+
this.discoveryService = discoveryService;
|
|
19
|
+
}
|
|
20
|
+
async getAuthConfig(request) {
|
|
21
|
+
const idpNames = this.envService.getIdpNames();
|
|
22
|
+
if (!idpNames.length) {
|
|
23
|
+
throw new HttpException({
|
|
24
|
+
message: 'Identity provider not found nor configured',
|
|
25
|
+
error: 'The identity provider is not present!',
|
|
26
|
+
statusCode: HttpStatus.NOT_FOUND,
|
|
27
|
+
}, HttpStatus.NOT_FOUND);
|
|
28
|
+
}
|
|
29
|
+
const baseDomainsToIdps = this.getBaseDomainsToIdp();
|
|
30
|
+
const defaultTenant = baseDomainsToIdps.find((x) => x.baseDomain === request.hostname);
|
|
31
|
+
if (defaultTenant) {
|
|
32
|
+
return await this.getAuthEnv(defaultTenant.idpName, defaultTenant.baseDomain);
|
|
33
|
+
}
|
|
34
|
+
for (const baseDomainToIdp of baseDomainsToIdps) {
|
|
35
|
+
const baseDomainRegex = this.getBaseDomainRegex(baseDomainToIdp.baseDomain);
|
|
36
|
+
const regExpExecArray = baseDomainRegex.exec(request.hostname);
|
|
37
|
+
if (!regExpExecArray) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const env = this.envService.getEnv();
|
|
41
|
+
const subDomain = regExpExecArray[1];
|
|
42
|
+
const subDomainIdpName = env.idpNames.includes(subDomain)
|
|
43
|
+
? subDomain
|
|
44
|
+
: baseDomainToIdp.idpName;
|
|
45
|
+
if (regExpExecArray.length > 1) {
|
|
46
|
+
return await this.getAuthEnv(subDomainIdpName, baseDomainToIdp.baseDomain, subDomain);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw new HttpException({
|
|
50
|
+
message: 'Domain not supported',
|
|
51
|
+
error: `${request.hostname} is not listed in the portal's base urls: '${baseDomainsToIdps
|
|
52
|
+
.map((x) => x.baseDomain)
|
|
53
|
+
.join(',')}'`,
|
|
54
|
+
statusCode: HttpStatus.NOT_FOUND,
|
|
55
|
+
}, HttpStatus.NOT_FOUND);
|
|
56
|
+
}
|
|
57
|
+
async getAuthEnv(idpName, baseDomain, subDomainIdpName) {
|
|
58
|
+
const env = this.envService.getEnv();
|
|
59
|
+
if (!env.idpNames.includes(idpName)) {
|
|
60
|
+
throw new HttpException({
|
|
61
|
+
message: 'Identity provider not configured',
|
|
62
|
+
error: `The idp '${idpName}' is not configured!`,
|
|
63
|
+
statusCode: HttpStatus.BAD_REQUEST,
|
|
64
|
+
}, HttpStatus.BAD_REQUEST);
|
|
65
|
+
}
|
|
66
|
+
const idpEnvName = this.formatIdpNameForEnvVar(idpName);
|
|
67
|
+
const oidcUrl = process.env[`DISCOVERY_ENDPOINT_${idpEnvName}`];
|
|
68
|
+
const oidc = await this.discoveryService.getOIDC(oidcUrl);
|
|
69
|
+
const oauthServerUrl = oidc?.authorization_endpoint ??
|
|
70
|
+
process.env[`AUTH_SERVER_URL_${idpEnvName}`];
|
|
71
|
+
const oauthTokenUrl = oidc?.token_endpoint ?? process.env[`TOKEN_URL_${idpEnvName}`];
|
|
72
|
+
const clientId = process.env[`OIDC_CLIENT_ID_${idpEnvName}`];
|
|
73
|
+
const clientSecretEnvVar = `OIDC_CLIENT_SECRET_${idpEnvName}`;
|
|
74
|
+
const clientSecret = process.env[clientSecretEnvVar];
|
|
75
|
+
if (!oauthServerUrl || !oauthTokenUrl || !clientId || !clientSecret) {
|
|
76
|
+
const hasClientSecret = !!clientSecret;
|
|
77
|
+
throw new HttpException({
|
|
78
|
+
message: 'Identity provider configuration incomplete',
|
|
79
|
+
error: `the idp ${idpName} is not properly configured. oauthServerUrl: '${oauthServerUrl}' oauthTokenUrl: '${oauthTokenUrl}' clientId: '${clientId}', has client secret (${clientSecretEnvVar}): ${String(hasClientSecret)}`,
|
|
80
|
+
statusCode: HttpStatus.NOT_FOUND,
|
|
81
|
+
}, HttpStatus.NOT_FOUND);
|
|
82
|
+
}
|
|
83
|
+
if (idpName === subDomainIdpName) {
|
|
84
|
+
baseDomain = `${subDomainIdpName}.${baseDomain}`;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
idpName,
|
|
88
|
+
baseDomain,
|
|
89
|
+
oauthServerUrl,
|
|
90
|
+
clientId,
|
|
91
|
+
clientSecret,
|
|
92
|
+
oauthTokenUrl,
|
|
93
|
+
oidcIssuerUrl: oidc?.issuer ?? '',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
getBaseDomainsToIdp() {
|
|
97
|
+
let baseDomains = [];
|
|
98
|
+
for (const idpName of this.envService.getIdpNames()) {
|
|
99
|
+
const idpEnvName = this.formatIdpNameForEnvVar(idpName);
|
|
100
|
+
const idpDomains = (process.env[`BASE_DOMAINS_${idpEnvName}`] || '')
|
|
101
|
+
.split(',')
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.map((baseDomain) => ({
|
|
104
|
+
idpName,
|
|
105
|
+
baseDomain,
|
|
106
|
+
}));
|
|
107
|
+
baseDomains.push(...idpDomains);
|
|
108
|
+
}
|
|
109
|
+
return baseDomains;
|
|
110
|
+
}
|
|
111
|
+
formatIdpNameForEnvVar(idpName) {
|
|
112
|
+
return idpName.toUpperCase().replace('-', '_');
|
|
113
|
+
}
|
|
114
|
+
getBaseDomainRegex(baseDomain) {
|
|
115
|
+
const domain = _.escapeRegExp(baseDomain);
|
|
116
|
+
return new RegExp(`(.*)\\.${domain}`);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
EnvAuthConfigService = __decorate([
|
|
120
|
+
Injectable(),
|
|
121
|
+
__metadata("design:paramtypes", [EnvService,
|
|
122
|
+
DiscoveryService])
|
|
123
|
+
], EnvAuthConfigService);
|
|
124
|
+
export { EnvAuthConfigService };
|
|
125
|
+
//# sourceMappingURL=auth-config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-config.service.js","sourceRoot":"","sources":["../../src/auth/auth-config.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,CAAC,MAAM,QAAQ,CAAC;AAuBhB,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAErB;IACA;IAFV,YACU,UAAsB,EACtB,gBAAkC;QADlC,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAkB;IACzC,CAAC;IAEG,KAAK,CAAC,aAAa,CAAC,OAAgB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,aAAa,CACrB;gBACE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,WAAW,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,sBAAsB,CAAC,OAAe;QAC5C,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAEO,kBAAkB,CAAC,UAAkB;QAC3C,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,IAAI,MAAM,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AA9JY,oBAAoB;IADhC,UAAU,EAAE;qCAGW,UAAU;QACJ,gBAAgB;GAHjC,oBAAoB,CA8JhC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CookiesService } from '../services/index.js';
|
|
2
|
+
import { AuthConfigService } from './auth-config.service.js';
|
|
3
|
+
import { HttpService } from '@nestjs/axios';
|
|
4
|
+
import type { Request, Response } from 'express';
|
|
5
|
+
export interface AuthTokenData {
|
|
6
|
+
access_token: string;
|
|
7
|
+
expires_in: string;
|
|
8
|
+
refresh_token: string;
|
|
9
|
+
refresh_expires_in: string;
|
|
10
|
+
id_token?: string;
|
|
11
|
+
token_type: string;
|
|
12
|
+
scope: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class AuthTokenService {
|
|
15
|
+
private authConfigService;
|
|
16
|
+
private httpService;
|
|
17
|
+
private cookiesService;
|
|
18
|
+
constructor(authConfigService: AuthConfigService, httpService: HttpService, cookiesService: CookiesService);
|
|
19
|
+
exchangeTokenForCode(request: Request, response: Response, code: string): Promise<AuthTokenData>;
|
|
20
|
+
exchangeTokenForRefreshToken(request: Request, response: Response, refreshToken: string): Promise<AuthTokenData>;
|
|
21
|
+
private requestToken;
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { AUTH_CONFIG_INJECTION_TOKEN } from '../injection-tokens.js';
|
|
14
|
+
import { CookiesService } from '../services/index.js';
|
|
15
|
+
import { getRedirectUri } from './redirect-uri.js';
|
|
16
|
+
import { HttpService } from '@nestjs/axios';
|
|
17
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
18
|
+
import { catchError, firstValueFrom } from 'rxjs';
|
|
19
|
+
let AuthTokenService = class AuthTokenService {
|
|
20
|
+
authConfigService;
|
|
21
|
+
httpService;
|
|
22
|
+
cookiesService;
|
|
23
|
+
constructor(authConfigService, httpService, cookiesService) {
|
|
24
|
+
this.authConfigService = authConfigService;
|
|
25
|
+
this.httpService = httpService;
|
|
26
|
+
this.cookiesService = cookiesService;
|
|
27
|
+
}
|
|
28
|
+
async exchangeTokenForCode(request, response, code) {
|
|
29
|
+
const authConfig = await this.authConfigService.getAuthConfig(request);
|
|
30
|
+
const redirectUri = getRedirectUri(request);
|
|
31
|
+
const body = new URLSearchParams({
|
|
32
|
+
client_id: authConfig.clientId,
|
|
33
|
+
grant_type: 'authorization_code',
|
|
34
|
+
redirect_uri: redirectUri,
|
|
35
|
+
code: code,
|
|
36
|
+
});
|
|
37
|
+
return this.requestToken(request, response, authConfig, body);
|
|
38
|
+
}
|
|
39
|
+
async exchangeTokenForRefreshToken(request, response, refreshToken) {
|
|
40
|
+
const authConfig = await this.authConfigService.getAuthConfig(request);
|
|
41
|
+
const body = new URLSearchParams({
|
|
42
|
+
grant_type: 'refresh_token',
|
|
43
|
+
refresh_token: refreshToken,
|
|
44
|
+
});
|
|
45
|
+
return this.requestToken(request, response, authConfig, body);
|
|
46
|
+
}
|
|
47
|
+
async requestToken(request, response, authConfig, body) {
|
|
48
|
+
const authorization = `${Buffer.from(`${authConfig.clientId}:${authConfig.clientSecret}`).toString('base64')}`;
|
|
49
|
+
const redirectUriMsg = body.get('grant_type') === 'authorization_code'
|
|
50
|
+
? `Redirect URI: ${body.get('redirect_uri')}`
|
|
51
|
+
: '';
|
|
52
|
+
const tokenFetchResult = await firstValueFrom(this.httpService
|
|
53
|
+
.post(authConfig.oauthTokenUrl, body, {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: `Basic ${authorization}`,
|
|
56
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
57
|
+
Accept: 'application/json',
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
.pipe(catchError((e) => {
|
|
61
|
+
throw new Error(`Error response from auth token server: ${e.toString()}.
|
|
62
|
+
${e.response.data['error']}: ${e.response.data['error_description']}.
|
|
63
|
+
${redirectUriMsg}`);
|
|
64
|
+
})));
|
|
65
|
+
if (tokenFetchResult.status === 200) {
|
|
66
|
+
this.cookiesService.setAuthCookie(request, response, tokenFetchResult.data);
|
|
67
|
+
return tokenFetchResult.data;
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Unexpected response code from auth token server: ${tokenFetchResult.status}, ${tokenFetchResult.statusText}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
AuthTokenService = __decorate([
|
|
73
|
+
Injectable(),
|
|
74
|
+
__param(0, Inject(AUTH_CONFIG_INJECTION_TOKEN)),
|
|
75
|
+
__metadata("design:paramtypes", [Object, HttpService,
|
|
76
|
+
CookiesService])
|
|
77
|
+
], AuthTokenService);
|
|
78
|
+
export { AuthTokenService };
|
|
79
|
+
//# sourceMappingURL=auth-token.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-token.service.js","sourceRoot":"","sources":["../../src/auth/auth-token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAa3C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGjB;IACA;IACA;IAJV,YAEU,iBAAoC,EACpC,WAAwB,EACxB,cAA8B;QAF9B,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,gBAAW,GAAX,WAAW,CAAa;QACxB,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAQG,KAAK,CAAC,oBAAoB,CAC/B,OAAgB,EAChB,QAAkB,EAClB,IAAY;QAEZ,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QAE5C,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;YAC/B,SAAS,EAAE,UAAU,CAAC,QAAQ;YAC9B,UAAU,EAAE,oBAAoB;YAChC,YAAY,EAAE,WAAW;YACzB,IAAI,EAAE,IAAI;SACX,CAAC,CAA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AC,QAAQ,EAAE;gBACpD,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC;gBACjE,cAAc,EAAE,CACnB,CAAC;QACJ,CAAC,CAAC,CACH,CACJ,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACpC,IAAI,CAAC,cAAc,CAAC,aAAa,CAC/B,OAAO,EACP,QAAQ,EACR,gBAAgB,CAAC,IAAI,CACtB,CAAC;YACF,OAAO,gBAAgB,CAAC,IAAI,CAAC;QAC/B,CAAC;QAED,MAAM,IAAI,KAAK,CACb,oDAAoD,gBAAgB,CAAC,MAAM,KAAK,gBAAgB,CAAC,UAAU,EAAE,CAC9G,CAAC;IACJ,CAAC;CACF,CAAA;AAlGY,gBAAgB;IAD5B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,2BAA2B,CAAC,CAAA;6CAEf,WAAW;QACR,cAAc;GAL7B,gBAAgB,CAkG5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthTokenData } from './auth-token.service.js';
|
|
2
|
+
import type { Request, Response } from 'express';
|
|
3
|
+
export interface AuthCallback {
|
|
4
|
+
handleSuccess(request: Request, response: Response, authTokenResponse: AuthTokenData): Promise<any>;
|
|
5
|
+
handleFailure(request: Request, response: Response): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare class NoopAuthCallback implements AuthCallback {
|
|
8
|
+
handleSuccess(request: Request, response: Response, authTokenResponse: AuthTokenData): Promise<void>;
|
|
9
|
+
handleFailure(request: Request, response: Response): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
let NoopAuthCallback = class NoopAuthCallback {
|
|
9
|
+
handleSuccess(request, response, authTokenResponse) {
|
|
10
|
+
return Promise.resolve();
|
|
11
|
+
}
|
|
12
|
+
handleFailure(request, response) {
|
|
13
|
+
return Promise.resolve();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
NoopAuthCallback = __decorate([
|
|
17
|
+
Injectable()
|
|
18
|
+
], NoopAuthCallback);
|
|
19
|
+
export { NoopAuthCallback };
|
|
20
|
+
//# sourceMappingURL=auth.callback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.callback.js","sourceRoot":"","sources":["../../src/auth/auth.callback.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAcrC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,aAAa,CACX,OAAgB,EAChB,QAAkB,EAClB,iBAAgC;QAEhC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,aAAa,CAAC,OAAgB,EAAE,QAAkB;QAChD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAZY,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAY5B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CookiesService } from '../services/index.js';
|
|
2
|
+
import { AuthTokenData, AuthTokenService } from './auth-token.service.js';
|
|
3
|
+
import { AuthCallback } from './auth.callback.js';
|
|
4
|
+
import type { Request, Response } from 'express';
|
|
5
|
+
export declare class AuthController {
|
|
6
|
+
private authCallbackService;
|
|
7
|
+
private cookiesService;
|
|
8
|
+
private authTokenService;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(authCallbackService: AuthCallback, cookiesService: CookiesService, authTokenService: AuthTokenService);
|
|
11
|
+
auth(request: Request, response: Response): Response;
|
|
12
|
+
private isDomainOrSubdomain;
|
|
13
|
+
private createAppStateUrl;
|
|
14
|
+
refresh(request: Request, response: Response): Promise<AuthTokenData | void>;
|
|
15
|
+
private handleTokenRetrieval;
|
|
16
|
+
private handleAuthError;
|
|
17
|
+
private filterAuthTokenResponseForFrontend;
|
|
18
|
+
}
|