@webiny/app-security-access-management 0.0.0-mt-1

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -0
  3. package/components/GroupAutocomplete/graphql.d.ts +1 -0
  4. package/components/GroupAutocomplete/graphql.js +6 -0
  5. package/components/GroupAutocomplete/index.d.ts +2 -0
  6. package/components/GroupAutocomplete/index.js +16 -0
  7. package/components/NotAuthorizedError/NotAuthorizedError.d.ts +2 -0
  8. package/components/NotAuthorizedError/NotAuthorizedError.js +50 -0
  9. package/components/NotAuthorizedError/SecureRouteError.svg +1 -0
  10. package/components/NotAuthorizedError/index.d.ts +1 -0
  11. package/components/NotAuthorizedError/index.js +1 -0
  12. package/index.d.ts +2 -0
  13. package/index.js +4 -0
  14. package/package.json +70 -0
  15. package/plugins/constants.d.ts +4 -0
  16. package/plugins/constants.js +6 -0
  17. package/plugins/index.d.ts +3 -0
  18. package/plugins/index.js +8 -0
  19. package/plugins/installation.d.ts +3 -0
  20. package/plugins/installation.js +99 -0
  21. package/plugins/menus.d.ts +4 -0
  22. package/plugins/menus.js +61 -0
  23. package/plugins/permissionRenderer/SecurityPermissions.d.ts +5 -0
  24. package/plugins/permissionRenderer/SecurityPermissions.js +176 -0
  25. package/plugins/permissionRenderer/index.d.ts +3 -0
  26. package/plugins/permissionRenderer/index.js +21 -0
  27. package/plugins/routes.d.ts +3 -0
  28. package/plugins/routes.js +38 -0
  29. package/plugins/secureRouteError.d.ts +7 -0
  30. package/plugins/secureRouteError.js +10 -0
  31. package/ui/elements/GroupAutocompleteElement.d.ts +5 -0
  32. package/ui/elements/GroupAutocompleteElement.js +35 -0
  33. package/ui/views/ApiKeys/ApiKeyForm.d.ts +3 -0
  34. package/ui/views/ApiKeys/ApiKeyForm.js +244 -0
  35. package/ui/views/ApiKeys/ApiKeys.d.ts +3 -0
  36. package/ui/views/ApiKeys/ApiKeys.js +12 -0
  37. package/ui/views/ApiKeys/ApiKeysDataList.d.ts +3 -0
  38. package/ui/views/ApiKeys/ApiKeysDataList.js +209 -0
  39. package/ui/views/ApiKeys/graphql.d.ts +5 -0
  40. package/ui/views/ApiKeys/graphql.js +11 -0
  41. package/ui/views/ApiKeys/index.d.ts +1 -0
  42. package/ui/views/ApiKeys/index.js +1 -0
  43. package/ui/views/ApiKeys/utils.d.ts +1 -0
  44. package/ui/views/ApiKeys/utils.js +5 -0
  45. package/ui/views/Groups/Groups.d.ts +3 -0
  46. package/ui/views/Groups/Groups.js +12 -0
  47. package/ui/views/Groups/GroupsDataList.d.ts +3 -0
  48. package/ui/views/Groups/GroupsDataList.js +215 -0
  49. package/ui/views/Groups/GroupsForm.d.ts +3 -0
  50. package/ui/views/Groups/GroupsForm.js +234 -0
  51. package/ui/views/Groups/graphql.d.ts +5 -0
  52. package/ui/views/Groups/graphql.js +11 -0
  53. package/ui/views/Groups/index.d.ts +1 -0
  54. package/ui/views/Groups/index.js +1 -0
  55. package/ui/views/utils.d.ts +2 -0
  56. package/ui/views/utils.js +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @webiny/app-security
2
+ [![](https://img.shields.io/npm/dw/@webiny/app-security.svg)](https://www.npmjs.com/package/@webiny/app-security)
3
+ [![](https://img.shields.io/npm/v/@webiny/app-security.svg)](https://www.npmjs.com/package/@webiny/app-security)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ Exposes a simple `SecurityProvider` React provider component and enables you to quickly retrieve the currently signed-in user via the `useSecurity` React hook.
8
+
9
+ ## Install
10
+ ```
11
+ npm install --save @webiny/app-security
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+ ```
16
+ yarn add @webiny/app-security
17
+ ```
18
+
19
+ ## Quick Example
20
+
21
+ First, make sure you mount the `SecurityProvider` React provider component in your application's entrypoint component, for example the `App` component:
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { Routes } from "@webiny/app/components/Routes";
26
+ import { BrowserRouter } from "@webiny/react-router";
27
+ import { SecurityProvider } from "@webiny/app-security";
28
+ import Authenticator from "./components/Authenticator";
29
+
30
+ export const App = () => (
31
+ <>
32
+ {/*
33
+ <SecurityProvider> is a generic provider of identity information. 3rd party identity providers (like Cognito,
34
+ Okta, Auth0) will handle the authentication, and set the information about the user into this provider,
35
+ so other parts of the system have a centralized place to fetch user information from.
36
+ */}
37
+ <SecurityProvider>
38
+ {/* This is the component that might trigger the initial authentication
39
+ process and set the retrieved user data into the Security provider.*/}
40
+ <Authenticator>
41
+ <BrowserRouter basename={process.env.PUBLIC_URL}>
42
+ <Routes />
43
+ </BrowserRouter>
44
+ </Authenticator>
45
+ </SecurityProvider>
46
+ </>
47
+ );
48
+ ```
49
+
50
+ A simple `Authenticator` React component (uses Amazon Cognito and AWS Amplify's [`Auth`](https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/Auth.ts#L100) class):
51
+
52
+ ```tsx
53
+ import React, { useEffect } from "react";
54
+ import Auth from "@aws-amplify/auth";
55
+ import { useSecurity, SecurityIdentity } from "@webiny/app-security";
56
+
57
+ // Apart from the React component, we also configure the Auth class here.
58
+ Auth.configure({
59
+ region: process.env.REACT_APP_USER_POOL_REGION,
60
+ userPoolId: process.env.REACT_APP_USER_POOL_ID,
61
+ userPoolWebClientId: process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID,
62
+ oauth: {
63
+ domain: process.env.REACT_APP_USER_POOL_DOMAIN,
64
+ redirectSignIn: `${location.origin}?signIn`,
65
+ redirectSignOut: `${location.origin}?signOut`,
66
+ responseType: "token"
67
+ }
68
+ });
69
+
70
+ // The `Authenticator` component.
71
+ const Authenticator: React.FC = props => {
72
+ const { setIdentity } = useSecurity();
73
+
74
+ useEffect(() => {
75
+ // Get the currently signed-in user.
76
+ Auth.currentSession().then(response => {
77
+ const user = response.getIdToken().payload;
78
+ setIdentity(
79
+ new SecurityIdentity({
80
+ login: user.email,
81
+ firstName: user.given_name,
82
+ lastName: user.family_name,
83
+ logout: () => {
84
+ Auth.signOut();
85
+ setIdentity(null);
86
+ }
87
+ })
88
+ );
89
+ }).catch(() => { /* Do nothing. */ });
90
+ }, []);
91
+
92
+ return <>{props.children}</>;
93
+ };
94
+
95
+ export default Authenticator;
96
+ ```
97
+
98
+ Finally, use the `useSecurity` React hook in any of your components:
99
+
100
+ ```tsx
101
+ import React from "react";
102
+ import { useSecurity } from "@webiny/app-security";
103
+
104
+ const MyComponent: React.FC = () => {
105
+ const { identity } = useSecurity();
106
+
107
+ if (identity) {
108
+ return <>Logged in.</>;
109
+ }
110
+
111
+ return <>Not logged in.</>;
112
+ };
113
+
114
+ export default MyComponent;
115
+ ```
@@ -0,0 +1 @@
1
+ export declare const LIST_GROUPS: any;
@@ -0,0 +1,6 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
5
+ import gql from "graphql-tag";
6
+ export var LIST_GROUPS = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query listGroups {\n security {\n groups: listGroups {\n data {\n id\n slug\n name\n description\n createdOn\n }\n }\n }\n }\n"])));
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const GroupAutocomplete: (props: any) => JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { AutoComplete } from "@webiny/ui/AutoComplete";
3
+ import { LIST_GROUPS } from "./graphql";
4
+ import { useQuery } from "@apollo/react-hooks";
5
+ export var GroupAutocomplete = function GroupAutocomplete(props) {
6
+ var _useQuery = useQuery(LIST_GROUPS),
7
+ data = _useQuery.data,
8
+ loading = _useQuery.loading;
9
+
10
+ var options = loading && !data ? [] : data.security.groups.data;
11
+ return /*#__PURE__*/React.createElement(AutoComplete, Object.assign({}, props, {
12
+ options: options,
13
+ valueProp: "id",
14
+ value: loading ? null : props.value
15
+ }));
16
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const NotAuthorizedError: () => JSX.Element;
@@ -0,0 +1,50 @@
1
+ import * as React from "react";
2
+ import { Link } from "@webiny/react-router";
3
+ import { css } from "emotion";
4
+ import styled from "@emotion/styled";
5
+ import Helmet from "react-helmet";
6
+ import authErrorImg from "./SecureRouteError.svg";
7
+ import { Typography } from "@webiny/ui/Typography";
8
+ var ContentWrapper = /*#__PURE__*/styled("div", {
9
+ target: "e18nns4o0",
10
+ label: "ContentWrapper"
11
+ })({
12
+ display: "block",
13
+ paddingTop: "15%",
14
+ textAlign: "center",
15
+ margin: "auto"
16
+ });
17
+ var styles = {
18
+ authErrorImgStyle: /*#__PURE__*/css({
19
+ width: "192px",
20
+ paddingBottom: "24px"
21
+ }, "label:authErrorImgStyle;"),
22
+ bodyStyle: /*#__PURE__*/css({
23
+ color: "var(--mdc-theme-text-primary-on-background)",
24
+ display: "block"
25
+ }, "label:bodyStyle;"),
26
+ linkStyle: /*#__PURE__*/css({
27
+ textDecoration: "none",
28
+ "&:hover": {
29
+ textDecoration: "none"
30
+ }
31
+ }, "label:linkStyle;")
32
+ };
33
+ export var NotAuthorizedError = function NotAuthorizedError() {
34
+ return /*#__PURE__*/React.createElement(ContentWrapper, null, /*#__PURE__*/React.createElement(Helmet, {
35
+ title: "Not authorized"
36
+ }), /*#__PURE__*/React.createElement("img", {
37
+ className: styles.authErrorImgStyle,
38
+ src: authErrorImg,
39
+ alt: "Not Authorized"
40
+ }), /*#__PURE__*/React.createElement(Typography, {
41
+ use: "body1",
42
+ className: styles.bodyStyle
43
+ }, "You are not authorized to view this route."), /*#__PURE__*/React.createElement(Typography, {
44
+ use: "body1",
45
+ className: styles.bodyStyle
46
+ }, "Please contact your administrator to request access."), /*#__PURE__*/React.createElement(Link, {
47
+ to: "/",
48
+ className: styles.linkStyle
49
+ }, "Take me back."));
50
+ };
@@ -0,0 +1 @@
1
+ <svg id="ffa0e257-4b46-4632-a8d6-93195cbf254d" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="895.68" height="517.48" viewBox="0 0 895.68 517.48"><defs><linearGradient id="74471b12-b6be-488b-b2aa-2815e91483d9" x1="790.94" y1="640.76" x2="790.94" y2="264.76" gradientTransform="translate(1229.99 -336.2) rotate(90)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient><linearGradient id="f5c756da-9879-448e-9194-9478f83d355f" x1="785.97" y1="446.14" x2="785.97" y2="321.91" gradientTransform="translate(1166.67 -399.94) rotate(90)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="5c9be04e-db0f-4829-87c1-2cfa193e30b8" x1="660.92" y1="518.19" x2="660.92" y2="494.17" gradientTransform="translate(1146.84 -172.9) rotate(90)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="b92f3a53-b4d2-4abd-916c-aeb632188996" x1="433.66" y1="605.23" x2="433.66" y2="235.23" gradientTransform="translate(13.58 8.51)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="44577794-7f8e-40ae-89fc-019e5bfac17e" x1="428.36" y1="413.71" x2="428.36" y2="291.46" gradientTransform="translate(-1.05 11.3)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="666bb7d3-84d0-4835-ad07-c313c2384f21" x1="295.22" y1="484.61" x2="295.22" y2="460.98" gradientTransform="translate(28.38 37.45)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="59939605-05af-4a9a-9980-f700897f3f8b" x1="455.07" y1="464.48" x2="455.07" y2="10.48" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="6c0ba2ee-2d81-48f4-b4cf-f21b525fcc13" x1="449.07" y1="229.48" x2="449.07" y2="79.48" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="45b0c09d-2995-447e-8cb2-7f6b59b5e20c" x1="298.07" y1="316.48" x2="298.07" y2="287.48" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="e5b0a96a-81f6-4370-afe3-5a7d6a35b55e" x1="457.07" y1="517.48" x2="457.07" y2="364.48" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="a1850e5a-cf77-4889-926a-0125112ab273" x1="611.23" y1="564.74" x2="611.23" y2="464.74" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/><linearGradient id="66998849-614e-4d8a-b9ff-f14bbc588ed8" x1="611.23" y1="660.74" x2="611.23" y2="602.74" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#74471b12-b6be-488b-b2aa-2815e91483d9"/></defs><title>safe</title><rect x="792.23" y="49.92" width="19.88" height="470.41" transform="translate(247.6 844.09) rotate(-81.36)" fill="#f5f5f5"/><rect x="589.23" y="209.59" width="376" height="490.29" transform="translate(58.72 963.57) rotate(-81.36)" fill="url(#74471b12-b6be-488b-b2aa-2815e91483d9)"/><rect x="603.48" y="229.23" width="342.87" height="470.41" transform="translate(47.16 969.52) rotate(-81.36)" fill="#f5f5f5"/><circle cx="580.99" cy="251.51" r="4.86" transform="translate(92.88 596.86) rotate(-81.36)" fill="#ff5252"/><circle cx="594.2" cy="253.52" r="4.86" transform="translate(102.12 611.62) rotate(-81.36)" fill="#ff0"/><circle cx="607.41" cy="255.53" r="4.86" transform="translate(111.36 626.39) rotate(-81.36)" fill="#69f0ae"/><rect x="720.53" y="174.84" width="124.23" height="422.38" transform="translate(131.25 910.54) rotate(-81.36)" fill="url(#f5c756da-9879-448e-9194-9478f83d355f)"/><rect x="576.36" y="328.95" width="413.27" height="115.12" transform="translate(-85.2 -304.51) rotate(8.64)" fill="#fa5a28"/><rect x="628.65" y="473.94" width="24.02" height="28.16" transform="translate(-90.24 856.82) rotate(-81.36)" fill="url(#5c9be04e-db0f-4829-87c1-2cfa193e30b8)"/><rect x="627.88" y="477.73" width="26.5" height="19.88" transform="translate(-71.61 -282.05) rotate(8.64)" fill="#fa5a28"/><rect x="622.77" y="511.3" width="26.5" height="19.88" transform="translate(-66.63 -280.9) rotate(8.64)" fill="#ff5252"/><rect x="617.67" y="544.87" width="26.5" height="19.88" transform="translate(-61.64 -279.75) rotate(8.64)" fill="#ff9800"/><rect x="696.41" y="506.51" width="213.67" height="11.59" transform="translate(-66.07 -306.13) rotate(8.64)" fill="#fa5a28" opacity="0.4"/><rect x="691.31" y="540.08" width="213.67" height="11.59" transform="translate(-61.09 -304.98) rotate(8.64)" fill="#fa5a28" opacity="0.4"/><rect x="686.21" y="573.65" width="213.67" height="11.59" transform="translate(-56.1 -303.83) rotate(8.64)" fill="#fa5a28" opacity="0.4"/><rect x="159.15" y="254.51" width="500.84" height="19.56" transform="translate(-199.95 -95.55) rotate(-12.6)" fill="#f5f5f5"/><rect x="186.23" y="243.74" width="522" height="370" transform="translate(-234.92 -83.38) rotate(-12.6)" fill="url(#b92f3a53-b4d2-4abd-916c-aeb632188996)"/><rect x="198.08" y="269.78" width="500.84" height="337.4" transform="translate(-237.01 -82.86) rotate(-12.6)" fill="#f5f5f5"/><ellipse cx="177.11" cy="316.25" rx="5.17" ry="4.78" transform="translate(-216.88 -145.01) rotate(-12.6)" fill="#ff5252"/><ellipse cx="191" cy="313.15" rx="5.17" ry="4.78" transform="translate(-215.87 -142.05) rotate(-12.6)" fill="#ff0"/><ellipse cx="204.88" cy="310.05" rx="5.17" ry="4.78" transform="translate(-214.86 -139.1) rotate(-12.6)" fill="#69f0ae"/><rect x="202.46" y="302.76" width="449.7" height="122.25" transform="translate(-221.25 -89.28) rotate(-12.6)" fill="url(#44577794-7f8e-40ae-89fc-019e5bfac17e)"/><rect x="207.83" y="307.54" width="440" height="113.28" transform="translate(-221.3 -89.16) rotate(-12.6)" fill="#fa5a28"/><rect x="308.61" y="498.42" width="29.98" height="23.63" transform="translate(-255.67 -108.38) rotate(-12.6)" fill="url(#666bb7d3-84d0-4835-ad07-c313c2384f21)"/><rect x="309.83" y="499.96" width="28.22" height="19.56" transform="matrix(0.98, -0.22, 0.22, 0.98, -255.56, -108.32)" fill="#fa5a28"/><rect x="317.12" y="532.57" width="28.22" height="19.56" transform="translate(-262.49 -105.94) rotate(-12.6)" fill="#ff5252"/><rect x="324.41" y="565.18" width="28.22" height="19.56" transform="matrix(0.98, -0.22, 0.22, 0.98, -269.43, -103.57)" fill="#ff9800"/><rect x="380.57" y="465.95" width="227.49" height="11.41" transform="translate(-243.14 -72.07) rotate(-12.6)" fill="#fa5a28" opacity="0.4"/><rect x="387.86" y="498.56" width="227.49" height="11.41" transform="translate(-250.08 -69.69) rotate(-12.6)" fill="#fa5a28" opacity="0.4"/><rect x="395.15" y="531.17" width="227.49" height="11.41" transform="translate(-257.02 -67.32) rotate(-12.6)" fill="#fa5a28" opacity="0.4"/><rect x="170.07" y="18.48" width="568" height="24" fill="#f5f5f5"/><rect x="159.07" y="10.48" width="592" height="454" fill="url(#59939605-05af-4a9a-9980-f700897f3f8b)"/><rect x="170.07" y="42.48" width="568" height="414" fill="#fff"/><circle cx="183.94" cy="30.48" r="5.87" fill="#ff5252"/><circle cx="200.07" cy="30.48" r="5.87" fill="#ff0"/><circle cx="216.2" cy="30.48" r="5.87" fill="#69f0ae"/><rect x="194.07" y="79.48" width="510" height="150" fill="url(#6c0ba2ee-2d81-48f4-b4cf-f21b525fcc13)"/><rect x="200.07" y="85.48" width="499" height="139" fill="#fa5a28"/><rect x="281.07" y="287.48" width="34" height="29" fill="url(#45b0c09d-2995-447e-8cb2-7f6b59b5e20c)"/><rect x="282.57" y="289.48" width="32" height="24" fill="#fa5a28"/><rect x="282.57" y="330.48" width="32" height="24" fill="#ff5252"/><rect x="282.57" y="371.48" width="32" height="24" fill="#ff9800"/><rect x="367.57" y="294.48" width="258" height="14" fill="#fa5a28" opacity="0.4"/><rect x="367.57" y="335.48" width="258" height="14" fill="#fa5a28" opacity="0.4"/><rect x="367.57" y="376.48" width="258" height="14" fill="#fa5a28" opacity="0.4"/><rect x="364.07" y="364.48" width="186" height="153" fill="url(#e5b0a96a-81f6-4370-afe3-5a7d6a35b55e)"/><path d="M559.15,531.41a52.08,52.08,0,0,1,104.17,0v33.33H677.9V531.41a66.67,66.67,0,1,0-133.33,0v33.33h14.58Z" transform="translate(-152.16 -191.26)" fill="url(#a1850e5a-cf77-4889-926a-0125112ab273)"/><path d="M561.23,530.74a50,50,0,0,1,100,0v32h14v-32a64,64,0,0,0-128,0v32h14Z" transform="translate(-152.16 -191.26)" fill="#fff"/><rect x="372.07" y="369.48" width="174" height="142" fill="#fa5a28"/><rect x="372.07" y="369.48" width="174" height="142" fill="#fff"/><rect x="372.07" y="397.48" width="174" height="86" fill="#fa5a28"/><path d="M624,615.5a12.76,12.76,0,1,0-22,8.74v27.22a9.28,9.28,0,0,0,18.56,0V624.24A12.7,12.7,0,0,0,624,615.5Z" transform="translate(-152.16 -191.26)" fill="url(#66998849-614e-4d8a-b9ff-f14bbc588ed8)"/><path d="M622.23,617.74a11,11,0,1,0-19,7.53v23.47a8,8,0,1,0,16,0V625.27A11,11,0,0,0,622.23,617.74Z" transform="translate(-152.16 -191.26)" opacity="0.2"/></svg>
@@ -0,0 +1 @@
1
+ export { NotAuthorizedError } from "./NotAuthorizedError";
@@ -0,0 +1 @@
1
+ export { NotAuthorizedError } from "./NotAuthorizedError";
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("@webiny/plugins/types").PluginCollection;
2
+ export default _default;
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import plugins from "./plugins";
2
+ export default (function () {
3
+ return plugins();
4
+ });
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@webiny/app-security-access-management",
3
+ "version": "0.0.0-mt-1",
4
+ "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/webiny/webiny-js.git"
8
+ },
9
+ "contributors": [
10
+ "Pavel Denisjuk <pavel@webiny.com>",
11
+ "Sven Al Hamad <sven@webiny.com>",
12
+ "Adrian Smijulj <adrian@webiny.com>"
13
+ ],
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "@apollo/react-hooks": "3.1.5",
17
+ "@emotion/styled": "10.0.27",
18
+ "@webiny/app": "0.0.0-mt-1",
19
+ "@webiny/app-admin": "0.0.0-mt-1",
20
+ "@webiny/app-security": "0.0.0-mt-1",
21
+ "@webiny/form": "0.0.0-mt-1",
22
+ "@webiny/plugins": "0.0.0-mt-1",
23
+ "@webiny/react-router": "0.0.0-mt-1",
24
+ "@webiny/ui": "0.0.0-mt-1",
25
+ "@webiny/validation": "0.0.0-mt-1",
26
+ "emotion": "10.0.27",
27
+ "graphql-tag": "2.12.5",
28
+ "lodash": "4.17.21",
29
+ "react": "16.14.0",
30
+ "react-dom": "16.14.0",
31
+ "react-helmet": "5.2.1"
32
+ },
33
+ "devDependencies": {
34
+ "@babel/cli": "^7.5.5",
35
+ "@babel/core": "^7.5.5",
36
+ "@babel/plugin-proposal-class-properties": "^7.5.5",
37
+ "@babel/preset-env": "^7.5.5",
38
+ "@babel/preset-react": "^7.0.0",
39
+ "@babel/preset-typescript": "^7.8.3",
40
+ "@webiny/cli": "^0.0.0-mt-1",
41
+ "@webiny/project-utils": "^0.0.0-mt-1",
42
+ "babel-plugin-emotion": "^9.2.8",
43
+ "babel-plugin-lodash": "^3.3.4",
44
+ "babel-plugin-named-asset-import": "^1.0.0-next.3e165448",
45
+ "rimraf": "^3.0.2",
46
+ "ttypescript": "^1.5.12",
47
+ "typescript": "^4.1.3"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public",
51
+ "directory": "dist"
52
+ },
53
+ "scripts": {
54
+ "build": "yarn webiny run build",
55
+ "watch": "yarn webiny run watch"
56
+ },
57
+ "svgo": {
58
+ "plugins": {
59
+ "removeViewBox": false
60
+ }
61
+ },
62
+ "adio": {
63
+ "ignore": {
64
+ "peerDependencies": [
65
+ "react-dom"
66
+ ]
67
+ }
68
+ },
69
+ "gitHead": "37736d8456a6ecb342a6c3645060bd9a3f2d4bb0"
70
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum Permission {
2
+ Groups = "security.group",
3
+ ApiKeys = "security.apiKey"
4
+ }
@@ -0,0 +1,6 @@
1
+ export var Permission;
2
+
3
+ (function (Permission) {
4
+ Permission["Groups"] = "security.group";
5
+ Permission["ApiKeys"] = "security.apiKey";
6
+ })(Permission || (Permission = {}));
@@ -0,0 +1,3 @@
1
+ import { PluginCollection } from "@webiny/plugins/types";
2
+ declare const _default: () => PluginCollection;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import routes from "./routes";
2
+ import menus from "./menus";
3
+ import installation from "./installation";
4
+ import permissionRenderer from "./permissionRenderer";
5
+ import secureRouteError from "./secureRouteError";
6
+ export default (function () {
7
+ return [routes, menus, installation, permissionRenderer, secureRouteError];
8
+ });
@@ -0,0 +1,3 @@
1
+ import { AdminInstallationPlugin } from "@webiny/app-admin/types";
2
+ declare const plugin: AdminInstallationPlugin;
3
+ export default plugin;
@@ -0,0 +1,99 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+
5
+ var _templateObject, _templateObject2;
6
+
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import React, { useState, useEffect } from "react";
9
+ import gql from "graphql-tag";
10
+ import { useApolloClient } from "@apollo/react-hooks";
11
+ import { Alert } from "@webiny/ui/Alert";
12
+ import { CircularProgress } from "@webiny/ui/Progress";
13
+ import { SimpleForm, SimpleFormContent } from "@webiny/app-admin/components/SimpleForm";
14
+ import styled from "@emotion/styled";
15
+ var SimpleFormPlaceholder = /*#__PURE__*/styled("div", {
16
+ target: "evolwsn0",
17
+ label: "SimpleFormPlaceholder"
18
+ })({
19
+ minHeight: 300,
20
+ minWidth: 400
21
+ });
22
+ var IS_INSTALLED = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query IsSecurityInstalled {\n security {\n version\n }\n }\n"])));
23
+ var INSTALL = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n mutation InstallSecurity {\n security {\n install {\n data\n error {\n code\n message\n }\n }\n }\n }\n"])));
24
+
25
+ var SecurityInstaller = function SecurityInstaller(_ref) {
26
+ var onInstalled = _ref.onInstalled;
27
+ var client = useApolloClient();
28
+
29
+ var _useState = useState(null),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ error = _useState2[0],
32
+ setError = _useState2[1];
33
+
34
+ useEffect(function () {
35
+ client.mutate({
36
+ mutation: INSTALL
37
+ }).then(function (_ref2) {
38
+ var data = _ref2.data;
39
+ var error = data.security.install.error;
40
+
41
+ if (error) {
42
+ setError(error.message);
43
+ return;
44
+ } // Just so the user sees the actual message.
45
+
46
+
47
+ setTimeout(onInstalled, 3000);
48
+ });
49
+ }, []);
50
+ var label = error ? /*#__PURE__*/React.createElement(Alert, {
51
+ title: "Something went wrong",
52
+ type: "danger"
53
+ }, error) : "Installing Security...";
54
+ return /*#__PURE__*/React.createElement(SimpleForm, null, /*#__PURE__*/React.createElement(CircularProgress, {
55
+ label: label
56
+ }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(SimpleFormPlaceholder, null)));
57
+ };
58
+
59
+ var plugin = {
60
+ name: "admin-installation-security",
61
+ type: "admin-installation",
62
+ title: "Security",
63
+ dependencies: ["admin-installation-tenancy"],
64
+ secure: false,
65
+ getInstalledVersion: function getInstalledVersion(_ref3) {
66
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
67
+ var client, _yield$client$query, data;
68
+
69
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
70
+ while (1) {
71
+ switch (_context.prev = _context.next) {
72
+ case 0:
73
+ client = _ref3.client;
74
+ _context.next = 3;
75
+ return client.query({
76
+ query: IS_INSTALLED
77
+ });
78
+
79
+ case 3:
80
+ _yield$client$query = _context.sent;
81
+ data = _yield$client$query.data;
82
+ return _context.abrupt("return", data.security.version);
83
+
84
+ case 6:
85
+ case "end":
86
+ return _context.stop();
87
+ }
88
+ }
89
+ }, _callee);
90
+ }))();
91
+ },
92
+ render: function render(_ref4) {
93
+ var onInstalled = _ref4.onInstalled;
94
+ return /*#__PURE__*/React.createElement(SecurityInstaller, {
95
+ onInstalled: onInstalled
96
+ });
97
+ }
98
+ };
99
+ export default plugin;
@@ -0,0 +1,4 @@
1
+ import { UIViewPlugin } from "@webiny/app-admin/ui/UIView";
2
+ import { NavigationView } from "@webiny/app-admin/ui/views/NavigationView";
3
+ declare const _default: UIViewPlugin<NavigationView>;
4
+ export default _default;
@@ -0,0 +1,61 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { NavigationMenuElement, TAGS } from "@webiny/app-admin/ui/elements/NavigationMenuElement";
4
+ import { Permission } from "./constants";
5
+ import { UIViewPlugin } from "@webiny/app-admin/ui/UIView";
6
+ import { NavigationView } from "@webiny/app-admin/ui/views/NavigationView";
7
+ export default new UIViewPlugin(NavigationView, /*#__PURE__*/function () {
8
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(view) {
9
+ var _view$getSecurityHook, identity, groups, apiKeys, mainMenu;
10
+
11
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
12
+ while (1) {
13
+ switch (_context.prev = _context.next) {
14
+ case 0:
15
+ _context.next = 2;
16
+ return view.isRendered();
17
+
18
+ case 2:
19
+ _view$getSecurityHook = view.getSecurityHook(), identity = _view$getSecurityHook.identity;
20
+ groups = identity.getPermission(Permission.Groups);
21
+ apiKeys = identity.getPermission(Permission.ApiKeys);
22
+
23
+ if (!(!groups && !apiKeys)) {
24
+ _context.next = 7;
25
+ break;
26
+ }
27
+
28
+ return _context.abrupt("return");
29
+
30
+ case 7:
31
+ mainMenu = view.getSettingsMenuElement().addElement(new NavigationMenuElement("accessManagement", {
32
+ label: "Access Management",
33
+ tags: [TAGS.UTILS]
34
+ }));
35
+
36
+ if (groups) {
37
+ mainMenu.addElement(new NavigationMenuElement("groups", {
38
+ label: "Groups",
39
+ path: "/access-management/groups"
40
+ }));
41
+ }
42
+
43
+ if (apiKeys) {
44
+ mainMenu.addElement(new NavigationMenuElement("apiKeys", {
45
+ label: "API Keys",
46
+ path: "/access-management/api-keys"
47
+ }));
48
+ }
49
+
50
+ case 10:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }
55
+ }, _callee);
56
+ }));
57
+
58
+ return function (_x) {
59
+ return _ref.apply(this, arguments);
60
+ };
61
+ }());
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const SecurityPermissions: ({ value, onChange }: {
3
+ value: any;
4
+ onChange: any;
5
+ }) => JSX.Element;