planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.2.2](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.2.1...decap-cms-backend-aws-cognito-github-proxy@3.2.2) (2024-08-13)
### Reverts
- Revert "Update dependencies (#7264)" ([22d483a](https://github.com/decaporg/decap-cms/commit/22d483a5b0c654071ae05735ac4f49abdc13d38c)), closes [#7264](https://github.com/decaporg/decap-cms/issues/7264)
## [3.2.1](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.2.0...decap-cms-backend-aws-cognito-github-proxy@3.2.1) (2024-08-13)
**Note:** Version bump only for package decap-cms-backend-aws-cognito-github-proxy
# [3.2.0](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.1.2...decap-cms-backend-aws-cognito-github-proxy@3.2.0) (2024-08-07)
### Bug Fixes
- fetch GitHub PR author name, fixes [#7232](https://github.com/decaporg/decap-cms/issues/7232) ([#7253](https://github.com/decaporg/decap-cms/issues/7253)) ([0e5335d](https://github.com/decaporg/decap-cms/commit/0e5335daba1b67816b4a0c24d1a2d9a185e3b54f))
## [3.1.2](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.1.1...decap-cms-backend-aws-cognito-github-proxy@3.1.2) (2024-03-21)
**Note:** Version bump only for package decap-cms-backend-aws-cognito-github-proxy
## [3.1.1](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.1.0...decap-cms-backend-aws-cognito-github-proxy@3.1.1) (2024-02-21)
### Bug Fixes
- gitlab pkce auth error ([#7110](https://github.com/decaporg/decap-cms/issues/7110)) ([bcd58d6](https://github.com/decaporg/decap-cms/commit/bcd58d6e117b4654b3e0dca173f7f8aaca8dabdf))
# [3.1.0](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-aws-cognito-github-proxy@3.1.0-beta.2...decap-cms-backend-aws-cognito-github-proxy@3.1.0) (2024-02-01)
**Note:** Version bump only for package decap-cms-backend-aws-cognito-github-proxy
# 3.1.0-beta.2 (2024-01-31)
**Note:** Version bump only for package decap-cms-backend-aws-cognito-github-proxy

View File

@@ -0,0 +1,22 @@
Copyright (c) 2016 Netlify <decap@p-m.si>
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,9 @@
# GitHub backend
An abstraction layer between the CMS and a proxied version of [Github](https://docs.github.com/en/rest).
## Code structure
`Implementation` - wraps [Github Backend](https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-lib-auth/README.md) for proxied version of Github.
`AuthenticationPage` - uses [lib-auth](https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-lib-auth/README.md) to create an AWS Cognito compatible generic Authentication page supporting PKCE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _base = _interopRequireDefault(require("@emotion/styled/base"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _decapCmsLibAuth = require("decap-cms-lib-auth");
var _decapCmsUiDefault = require("decap-cms-ui-default");
var _react2 = require("@emotion/react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const LoginButtonIcon = /*#__PURE__*/(0, _base.default)(_decapCmsUiDefault.Icon, {
target: "e1eykva80",
label: "LoginButtonIcon"
})(process.env.NODE_ENV === "production" ? {
name: "1gnqu05",
styles: "margin-right:18px"
} : {
name: "1gnqu05",
styles: "margin-right:18px",
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9BdXRoZW50aWNhdGlvblBhZ2UuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBTW9DIiwiZmlsZSI6Ii4uLy4uL3NyYy9BdXRoZW50aWNhdGlvblBhZ2UuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgU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cm4gKFxuICAgICAgPEF1dGhlbnRpY2F0aW9uUGFnZVxuICAgICAgICBvbkxvZ2luPXt0aGlzLmhhbmRsZUxvZ2lufVxuICAgICAgICBsb2dpbkRpc2FibGVkPXtpblByb2dyZXNzfVxuICAgICAgICBsb2dpbkVycm9yTWVzc2FnZT17dGhpcy5zdGF0ZS5sb2dpbkVycm9yfVxuICAgICAgICBsb2dvVXJsPXtjb25maWcubG9nb191cmx9XG4gICAgICAgIHNpdGVVcmw9e2NvbmZpZy5zaXRlX3VybH1cbiAgICAgICAgcmVuZGVyQnV0dG9uQ29udGVudD17KCkgPT4gKFxuICAgICAgICAgIDxSZWFjdC5GcmFnbWVudD5cbiAgICAgICAgICAgIDxMb2dpbkJ1dHRvbkljb24gdHlwZT1cImxpbmtcIiAvPiB7aW5Qcm9ncmVzcyA/IHQoJ2F1dGgubG9nZ2luZ0luJykgOiB0KCdhdXRoLmxvZ2luJyl9XG4gICAgICAgICAgPC9SZWFjdC5GcmFnbWVudD5cbiAgICAgICAgKX1cbiAgICAgICAgdD17dH1cbiAgICAgIC8+XG4gICAgKTtcbiAgfVxufVxuIl19 */",
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
class GenericPKCEAuthenticationPage extends _react.default.Component {
constructor(...args) {
super(...args);
_defineProperty(this, "state", {});
_defineProperty(this, "handleLogin", e => {
e.preventDefault();
this.auth.authenticate({
scope: 'https://api.github.com/repo openid email'
}, (err, data) => {
if (err) {
this.setState({
loginError: err.toString()
});
return;
}
this.props.onLogin(data);
});
});
}
componentDidMount() {
const {
base_url = '',
app_id = '',
auth_endpoint = 'oauth2/authorize',
auth_token_endpoint = 'oauth2/token'
} = this.props.config.backend;
this.auth = new _decapCmsLibAuth.PkceAuthenticator({
base_url,
auth_endpoint,
app_id,
auth_token_endpoint,
auth_token_endpoint_content_type: 'application/x-www-form-urlencoded; charset=utf-8'
});
// Complete authentication if we were redirected back to from the provider.
this.auth.completeAuth((err, data) => {
if (err) {
this.setState({
loginError: err.toString()
});
return;
}
this.props.onLogin(data);
});
}
render() {
const {
inProgress,
config,
t
} = this.props;
return (0, _react2.jsx)(_decapCmsUiDefault.AuthenticationPage, {
onLogin: this.handleLogin,
loginDisabled: inProgress,
loginErrorMessage: this.state.loginError,
logoUrl: config.logo_url,
siteUrl: config.site_url,
renderButtonContent: () => (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(LoginButtonIcon, {
type: "link"
}), " ", inProgress ? t('auth.loggingIn') : t('auth.login')),
t: t
});
}
}
exports.default = GenericPKCEAuthenticationPage;
_defineProperty(GenericPKCEAuthenticationPage, "propTypes", {
inProgress: _propTypes.default.bool,
config: _propTypes.default.object.isRequired,
onLogin: _propTypes.default.func.isRequired,
t: _propTypes.default.func.isRequired
});

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _decapCmsBackendGithub = require("decap-cms-backend-github");
var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
var _react2 = require("@emotion/react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
class AwsCognitoGitHubProxyBackend extends _decapCmsBackendGithub.GitHubBackend {
constructor(config, options = {}) {
super(config, options);
this.bypassWriteAccessCheckForAppTokens = true;
this.tokenKeyword = 'Bearer';
}
authComponent() {
const wrappedAuthenticationPage = props => (0, _react2.jsx)(_AuthenticationPage.default, _extends({}, props, {
backend: this
}));
wrappedAuthenticationPage.displayName = 'AuthenticationPage';
return wrappedAuthenticationPage;
}
async currentUser({
token
}) {
if (!this._currentUserPromise) {
this._currentUserPromise = fetch(this.baseUrl + '/oauth2/userInfo', {
headers: {
Authorization: `${this.tokenKeyword} ${token}`
}
}).then(async res => {
if (res.status == 401) {
this.logout();
return Promise.reject('Token expired');
}
const userInfo = await res.json();
const owner = this.originRepo.split('/')[1];
return {
name: userInfo.email,
login: owner,
avatar_url: `https://github.com/${owner}.png`
};
});
}
return this._currentUserPromise;
}
async getPullRequestAuthor(pullRequest) {
var _pullRequest$user;
return (_pullRequest$user = pullRequest.user) === null || _pullRequest$user === void 0 ? void 0 : _pullRequest$user.login;
}
}
exports.default = AwsCognitoGitHubProxyBackend;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "API", {
enumerable: true,
get: function () {
return _decapCmsBackendGithub.API;
}
});
Object.defineProperty(exports, "AuthenticationPage", {
enumerable: true,
get: function () {
return _AuthenticationPage.default;
}
});
Object.defineProperty(exports, "AwsCognitoGitHubProxyBackend", {
enumerable: true,
get: function () {
return _implementation.default;
}
});
exports.DecapCmsBackendAwsCognitoGithubProxy = void 0;
var _decapCmsBackendGithub = require("decap-cms-backend-github");
var _implementation = _interopRequireDefault(require("./implementation"));
var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const DecapCmsBackendAwsCognitoGithubProxy = exports.DecapCmsBackendAwsCognitoGithubProxy = {
AwsCognitoGitHubProxyBackend: _implementation.default,
API: _decapCmsBackendGithub.API,
AuthenticationPage: _AuthenticationPage.default
};

View File

@@ -0,0 +1,45 @@
{
"name": "decap-cms-backend-aws-cognito-github-proxy",
"description": "GitHub backend for Decap CMS proxied through AWS Cognito",
"version": "3.2.2",
"license": "MIT",
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-aws-cognito-github-proxy",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"main": "dist/decap-cms-backend-aws-cognito-github-proxy.js",
"keywords": [
"decap-cms",
"backend",
"github",
"aws-cognito"
],
"sideEffects": false,
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore **/__tests__ --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
},
"dependencies": {
"apollo-cache-inmemory": "^1.6.2",
"apollo-client": "^2.6.3",
"apollo-link-context": "^1.0.18",
"apollo-link-http": "^1.5.15",
"common-tags": "^1.8.0",
"graphql": "^15.0.0",
"graphql-tag": "^2.10.1",
"js-base64": "^3.0.0",
"semaphore": "^1.1.0"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"decap-cms-backend-github": "^3.0.0",
"decap-cms-lib-auth": "^3.0.0",
"decap-cms-lib-util": "^3.0.0",
"decap-cms-ui-default": "^3.0.0",
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0"
},
"gitHead": "64d91b8bb3d0a93dd36c53800cdac4ba2e435000"
}

View File

@@ -0,0 +1,74 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { PkceAuthenticator } from 'decap-cms-lib-auth';
import { AuthenticationPage, Icon } from 'decap-cms-ui-default';
const LoginButtonIcon = styled(Icon)`
margin-right: 18px;
`;
export default class GenericPKCEAuthenticationPage extends React.Component {
static propTypes = {
inProgress: PropTypes.bool,
config: PropTypes.object.isRequired,
onLogin: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
};
state = {};
componentDidMount() {
const {
base_url = '',
app_id = '',
auth_endpoint = 'oauth2/authorize',
auth_token_endpoint = 'oauth2/token',
} = this.props.config.backend;
this.auth = new PkceAuthenticator({
base_url,
auth_endpoint,
app_id,
auth_token_endpoint,
auth_token_endpoint_content_type: 'application/x-www-form-urlencoded; charset=utf-8',
});
// Complete authentication if we were redirected back to from the provider.
this.auth.completeAuth((err, data) => {
if (err) {
this.setState({ loginError: err.toString() });
return;
}
this.props.onLogin(data);
});
}
handleLogin = e => {
e.preventDefault();
this.auth.authenticate({ scope: 'https://api.github.com/repo openid email' }, (err, data) => {
if (err) {
this.setState({ loginError: err.toString() });
return;
}
this.props.onLogin(data);
});
};
render() {
const { inProgress, config, t } = this.props;
return (
<AuthenticationPage
onLogin={this.handleLogin}
loginDisabled={inProgress}
loginErrorMessage={this.state.loginError}
logoUrl={config.logo_url}
siteUrl={config.site_url}
renderButtonContent={() => (
<React.Fragment>
<LoginButtonIcon type="link" /> {inProgress ? t('auth.loggingIn') : t('auth.login')}
</React.Fragment>
)}
t={t}
/>
);
}
}

View File

@@ -0,0 +1,52 @@
import * as React from 'react';
import { GitHubBackend } from 'decap-cms-backend-github';
import AuthenticationPage from './AuthenticationPage';
import type { GitHubUser } from 'decap-cms-backend-github/src/implementation';
import type { Config } from 'decap-cms-lib-util/src';
import type { Octokit } from '@octokit/rest';
export default class AwsCognitoGitHubProxyBackend extends GitHubBackend {
constructor(config: Config, options = {}) {
super(config, options);
this.bypassWriteAccessCheckForAppTokens = true;
this.tokenKeyword = 'Bearer';
}
authComponent() {
const wrappedAuthenticationPage = (props: Record<string, unknown>) => (
<AuthenticationPage {...props} backend={this} />
);
wrappedAuthenticationPage.displayName = 'AuthenticationPage';
return wrappedAuthenticationPage;
}
async currentUser({ token }: { token: string }): Promise<GitHubUser> {
if (!this._currentUserPromise) {
this._currentUserPromise = fetch(this.baseUrl + '/oauth2/userInfo', {
headers: {
Authorization: `${this.tokenKeyword} ${token}`,
},
}).then(async (res: Response): Promise<GitHubUser> => {
if (res.status == 401) {
this.logout();
return Promise.reject('Token expired');
}
const userInfo = await res.json();
const owner = this.originRepo.split('/')[1];
return {
name: userInfo.email,
login: owner,
avatar_url: `https://github.com/${owner}.png`,
} as GitHubUser;
});
}
return this._currentUserPromise;
}
async getPullRequestAuthor(pullRequest: Octokit.PullsListResponseItem) {
return pullRequest.user?.login;
}
}

View File

@@ -0,0 +1,12 @@
import { API } from 'decap-cms-backend-github';
import AwsCognitoGitHubProxyBackend from './implementation';
import AuthenticationPage from './AuthenticationPage';
export const DecapCmsBackendAwsCognitoGithubProxy = {
AwsCognitoGitHubProxyBackend,
API,
AuthenticationPage,
};
export { AwsCognitoGitHubProxyBackend, API, AuthenticationPage };

View File

@@ -0,0 +1,3 @@
const { getConfig } = require('../../scripts/webpack.js');
module.exports = getConfig();