Skip to content

Commit

Permalink
alteracoes
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusdaluz committed Oct 18, 2018
1 parent cd9d688 commit 376bc1c
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -12,5 +12,5 @@ node
build
build.config.js.sample
cache
cache/


2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "Globo Auth",
"repository": {
"type": "git",
"url": ""
"url": "https://gitlab.globoi.com/time-evolucao-infra/graylog-plugin-globo-auth"
},
"scripts": {
"build": "webpack --bail"
Expand Down
7 changes: 0 additions & 7 deletions pom.xml
Expand Up @@ -23,13 +23,6 @@
</developer>
</developers>

<scm>
<connection>scm:git:git@github.com:none.git</connection>
<developerConnection>scm:git:git@github.com:none.git</developerConnection>
<url>https://github.com/none</url>
<tag>HEAD</tag>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/globo/GloboAuthMetaData.java
Expand Up @@ -31,7 +31,7 @@ public String getAuthor() {

@Override
public URI getURL() {
return URI.create("https://github.com/none");
return URI.create("https://gitlab.globoi.com/time-evolucao-infra/graylog-plugin-globo-auth");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/globo/GloboAuthRealm.java
Expand Up @@ -16,7 +16,7 @@
public class GloboAuthRealm extends AuthenticatingRealm {
private static final Logger LOG = LoggerFactory.getLogger(GloboAuthRealm.class);

public static final String NAME = "Globo Auth";
public static final String NAME = "globo-oauth";

private final UserService userService = null;
private final ClusterConfigService clusterConfigService = null;
Expand Down
28 changes: 9 additions & 19 deletions src/web/index.jsx
@@ -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,
},
]
}));
8 changes: 8 additions & 0 deletions src/web/pages/GloboAuthActions.jsx
@@ -0,0 +1,8 @@
import Reflux from 'reflux';

const GloboAuthActions = Reflux.createActions({
config: { asyncResult: true },
saveConfig: { asyncResult: true },
});

export default GloboAuthActions;
69 changes: 69 additions & 0 deletions src/web/pages/GloboAuthConfiguration.jsx
@@ -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;
61 changes: 61 additions & 0 deletions src/web/pages/GloboAuthStore.jsx
@@ -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;
19 changes: 0 additions & 19 deletions src/web/pages/TestePage.jsx

This file was deleted.

0 comments on commit 376bc1c

Please sign in to comment.