diff --git a/dev-helpers/dev.yaml b/dev-helpers/dev.yaml
new file mode 100644
index 00000000..28ccb420
--- /dev/null
+++ b/dev-helpers/dev.yaml
@@ -0,0 +1,81 @@
+openapi: "3.0.0"
+info:
+ version: 1.0.0
+ title: Brentertainment OAuth2 Test Server
+ description: >
+ The server does not support CORS (yet?), so you need to take the strange step of disabling Same-Origin Policy in your browser.
+ [Here](https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/) are some instructions.
+ license:
+ name: MIT
+servers:
+ - url: http://brentertainment.com/oauth2/lockdin/
+paths:
+ /resource:
+ get:
+ description: Protected resource
+ security:
+ - oauth2AuthorizationCode: ["resource"]
+ - oauth2Implicit: ["resource"]
+ - oauth2Password: ["resource"]
+ - oauth2ClientCredentials: ["resource"]
+ - oauth2Multiflow: ["resource"]
+ responses:
+ 200:
+ description: the only response
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ type: string
+components:
+ securitySchemes:
+ oauth2AuthorizationCode:
+ type: oauth2
+ flows:
+ authorizationCode:
+ authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
+ oauth2Implicit:
+ type: oauth2
+ flows:
+ implicit:
+ authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
+ scopes:
+ resource: our only scope
+ oauth2Password:
+ type: oauth2
+ flows:
+ password:
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
+ oauth2ClientCredentials:
+ type: oauth2
+ flows:
+ clientCredentials:
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
+ oauth2Multiflow:
+ type: oauth2
+ flows:
+ clientCredentials:
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
+ password:
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
+ implicit:
+ authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
+ scopes:
+ resource: our only scope
+ authorizationCode:
+ authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
+ tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
+ scopes:
+ resource: our only scope
diff --git a/src/core/components/auth/auths.jsx b/src/core/components/auth/auths.jsx
index 98074512..532775f3 100644
--- a/src/core/components/auth/auths.jsx
+++ b/src/core/components/auth/auths.jsx
@@ -99,10 +99,13 @@ export default class Auths extends React.Component {
{
definitions.filter( schema => schema.get("type") === "oauth2")
.map( (schema, name) =>{
- return (
+ const { flow } = schema
+ const key = [name, flow].join("__").slice(0, -2)
+ return (
+ authId={ key }
+ name={ key || schema.get("name") || name } />
)
}
).toArray()
diff --git a/src/core/components/auth/oauth2.jsx b/src/core/components/auth/oauth2.jsx
index 86e6257b..dd018964 100644
--- a/src/core/components/auth/oauth2.jsx
+++ b/src/core/components/auth/oauth2.jsx
@@ -47,11 +47,11 @@ export default class Oauth2 extends React.Component {
}
authorize =() => {
- let { authActions, errActions, getConfigs, authSelectors } = this.props
+ let { authActions, errActions, getConfigs, authSelectors, authId } = this.props
let configs = getConfigs()
let authConfigs = authSelectors.getConfigs()
- errActions.clear({authId: name,type: "auth", source: "auth"})
+ errActions.clear({authId: authId ,type: "auth", source: "auth"})
oauth2Authorize({auth: this.state, authActions, errActions, configs, authConfigs })
}
@@ -79,15 +79,15 @@ export default class Oauth2 extends React.Component {
logout =(e) => {
e.preventDefault()
- let { authActions, errActions, name } = this.props
+ let { authActions, errActions, authId } = this.props
- errActions.clear({authId: name, type: "auth", source: "auth"})
- authActions.logout([ name ])
+ errActions.clear({authId: authId, type: "auth", source: "auth"})
+ authActions.logout([ authId ])
}
render() {
let {
- schema, getComponent, authSelectors, errSelectors, name, specSelectors
+ schema, getComponent, authSelectors, errSelectors, name, authId, specSelectors
} = this.props
const Input = getComponent("Input")
const Row = getComponent("Row")
@@ -107,9 +107,9 @@ export default class Oauth2 extends React.Component {
let flow = schema.get("flow")
let scopes = schema.get("allowedScopes") || schema.get("scopes")
- let authorizedAuth = authSelectors.authorized().get(name)
+ let authorizedAuth = authSelectors.authorized().get(authId)
let isAuthorized = !!authorizedAuth
- let errors = errSelectors.allErrors().filter( err => err.get("authId") === name)
+ let errors = errSelectors.allErrors().filter( err => err.get("authId") === authId)
let isValid = !errors.filter( err => err.get("source") === "validation").size
let description = schema.get("description")
diff --git a/src/core/plugins/oas3/auth-extensions/wrap-selectors.js b/src/core/plugins/oas3/auth-extensions/wrap-selectors.js
index 087466c1..faaf25e7 100644
--- a/src/core/plugins/oas3/auth-extensions/wrap-selectors.js
+++ b/src/core/plugins/oas3/auth-extensions/wrap-selectors.js
@@ -33,6 +33,7 @@ export const definitionsToAuthorize = onlyOAS3(createSelector(
definition.get("flows").entrySeq().forEach(([flowKey, flowVal]) => {
let translatedDef = fromJS({
flow: flowKey,
+ name: defName,
authorizationUrl: flowVal.get("authorizationUrl"),
tokenUrl: flowVal.get("tokenUrl"),
scopes: flowVal.get("scopes"),
@@ -40,7 +41,7 @@ export const definitionsToAuthorize = onlyOAS3(createSelector(
})
list = list.push(new Map({
- [defName]: translatedDef.filter((v) => {
+ [`${defName}__${flowKey}`]: translatedDef.filter((v) => {
// filter out unset values, sometimes `authorizationUrl`
// and `tokenUrl` come out as `undefined` in the data
return v !== undefined