Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd9d688
commit 376bc1c
Showing
10 changed files
with
151 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ node | |
build | ||
build.config.js.sample | ||
cache | ||
cache/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
import packageJson from '../../package.json'; | ||
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin'; | ||
|
||
import TestePage from 'pages/TestePage'; | ||
import GloboAuthConfiguration from 'pages/GloboAuthConfiguration'; | ||
|
||
PluginStore.register(new PluginManifest(packageJson, { | ||
/* This is the place where you define which entities you are providing to the web interface. | ||
Right now you can add routes and navigation elements to it. | ||
Examples: */ | ||
|
||
// Adding a route to /sample, rendering YourReactComponent when called: | ||
|
||
routes: [ | ||
{ path: '/teste', component: TestePage }, | ||
], | ||
|
||
// Adding an element to the top navigation pointing to /sample named "Sample": | ||
|
||
navigation: [ | ||
{ path: '/teste', description: 'Teste' }, | ||
], | ||
|
||
systemnavigation: [ | ||
{ path: '/teste', description: 'Teste' }, | ||
authenticatorConfigurations: [ | ||
{ | ||
name: 'globo-oauth', | ||
displayName: 'Globo OAuth', | ||
description: 'authenticates users based on Oauth 2.0 with backstage', | ||
canBeDisabled: true, | ||
component: GloboAuthConfiguration, | ||
}, | ||
] | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Reflux from 'reflux'; | ||
|
||
const GloboAuthActions = Reflux.createActions({ | ||
config: { asyncResult: true }, | ||
saveConfig: { asyncResult: true }, | ||
}); | ||
|
||
export default GloboAuthActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from "react"; | ||
import Reflux from "reflux"; | ||
import { Row, Col, Button, Alert } from "react-bootstrap"; | ||
import { Input } from 'components/bootstrap'; | ||
|
||
import { PageHeader, Spinner } from "components/common"; | ||
import GloboAuthActions from "./GloboAuthActions"; | ||
import GloboAuthStore from "./GloboAuthStore"; | ||
|
||
import StoreProvider from 'injection/StoreProvider'; | ||
const RolesStore = StoreProvider.getStore('Roles') | ||
|
||
import ObjectUtils from 'util/ObjectUtils'; | ||
|
||
const GloboAuthConfiguration = React.createClass({ | ||
|
||
mixins: [ | ||
Reflux.connect(GloboAuthStore), | ||
], | ||
|
||
componentDidMount() { | ||
GloboAuthActions.config(); | ||
RolesStore.loadRoles().done(roles => { | ||
this.setState({ roles: roles.map(role => role.name) }); | ||
}); | ||
}, | ||
|
||
saveSettings(ev) { | ||
ev.preventDefault(); | ||
GloboAuthActions.saveConfig(this.state.config); | ||
}, | ||
|
||
_setSetting(attribute, value) { | ||
const newState = {}; | ||
|
||
const settings = ObjectUtils.clone(this.state.config); | ||
settings[attribute] = value; | ||
newState.config = settings; | ||
this.setState(newState); | ||
}, | ||
|
||
_bindChecked(ev, value) { | ||
this._setSetting(ev.target.name, typeof value === 'undefined' ? ev.target.checked : value); | ||
}, | ||
|
||
_bindValue(ev) { | ||
this._setSetting(ev.target.name, ev.target.value); | ||
}, | ||
|
||
render() { | ||
let content; | ||
content = ( | ||
<h1>teste</h1> | ||
); | ||
|
||
return ( | ||
<div> | ||
<PageHeader title="Globo Oauth" subpage> | ||
<span>Configuration page for the Oauth.</span> | ||
</PageHeader> | ||
{content} | ||
</div> | ||
); | ||
} | ||
|
||
|
||
}); | ||
|
||
export default GloboAuthConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Reflux from 'reflux'; | ||
|
||
import GloboAuthActions from './GloboAuthActions'; | ||
|
||
import UserNotification from 'util/UserNotification'; | ||
import URLUtils from 'util/URLUtils'; | ||
import fetch from 'logic/rest/FetchProvider'; | ||
|
||
const urlPrefix = '/plugins/com.globo'; | ||
|
||
const GloboAuthStore = Reflux.createStore({ | ||
listenables: [GloboAuthActions], | ||
|
||
getInitialState() { | ||
return { | ||
config: undefined, | ||
}; | ||
}, | ||
|
||
_errorHandler(message, title, cb) { | ||
return (error) => { | ||
let errorMessage; | ||
try { | ||
errorMessage = error.additional.body.message; | ||
} catch (e) { | ||
errorMessage = error.message; | ||
} | ||
UserNotification.error(`${message}: ${errorMessage}`, title); | ||
if (cb) { | ||
cb(error); | ||
} | ||
}; | ||
}, | ||
|
||
_url(path) { | ||
return URLUtils.qualifyUrl(`${urlPrefix}${path}`); | ||
}, | ||
|
||
config() { | ||
const promise = fetch('GET', this._url('/config')); | ||
|
||
promise.then((response) => { | ||
this.trigger({ config: response }); | ||
}, this._errorHandler('Fetching config failed', 'Could not retrieve Globo Oauth')); | ||
|
||
GloboAuthActions.config.promise(promise); | ||
}, | ||
|
||
saveConfig(config) { | ||
const promise = fetch('PUT', this._url('/config'), config); | ||
|
||
promise.then((response) => { | ||
this.trigger({ config: response }); | ||
UserNotification.success('Globo Oauth configuration was updated successfully'); | ||
}, this._errorHandler('Updating Globo Oauth config failed', 'Unable to update Oauth authenticator config')); | ||
|
||
GloboAuthActions.saveConfig.promise(promise); | ||
}, | ||
}); | ||
|
||
export default GloboAuthStore; |
This file was deleted.
Oops, something went wrong.