提交 f7844728 编写于 作者: K Kyle Shockey

WIP

上级 c888daf9
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
......@@ -99,10 +99,13 @@ export default class Auths extends React.Component {
{
definitions.filter( schema => schema.get("type") === "oauth2")
.map( (schema, name) =>{
return (<div key={ name }>
const { flow } = schema
const key = [name, flow].join("__").slice(0, -2)
return (<div key={ key }>
<Oauth2 authorized={ authorized }
schema={ schema }
name={ name } />
authId={ key }
name={ key || schema.get("name") || name } />
</div>)
}
).toArray()
......
......@@ -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")
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册