Skip to content

Commit

Permalink
feat(admin): admin-related web APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
emirotin committed Aug 29, 2018
1 parent cbb69e7 commit 34cdf69
Show file tree
Hide file tree
Showing 44 changed files with 1,226 additions and 866 deletions.
28 changes: 0 additions & 28 deletions packages/admin/_back/api/common/util.js

This file was deleted.

9 changes: 0 additions & 9 deletions packages/admin/_back/api/index.js
Expand Up @@ -8,12 +8,9 @@ import Util from './common/util'
import AuthenticationService from '~/services/authentication'

import pairing from './pairing'
import basicLogin from './basic-login'
import tokenLogin from './token-login'
import wellKnown from './wellKnown'
import teams from './teams'
import bots from './bots'
import RESOURCES from '../lib/permissions'

export default ({ config, db }) => {
const api = Router()
Expand All @@ -25,18 +22,12 @@ export default ({ config, db }) => {

api.use('/pairing', pairing({ config, db }))

api.use('/teams', checkCloudAuth({ config, db }), loadUser, teams({ config, db }))

api.use('/bots', checkCloudAuth({ config, db }), bots({ config, db }))

api.use('/login', checkCloudAuth({ config, db }), loadUser, tokenLogin({ config, db }))

api.use('/.well-known', cache('30 minutes'), wellKnown({ config, db }))

api.get('/permissions', (req, res) => {
res.json(RESOURCES)
})

api.get('/', (req, res) => {
res.json({ version })
})
Expand Down
251 changes: 0 additions & 251 deletions packages/admin/_back/api/teams.js

This file was deleted.

38 changes: 1 addition & 37 deletions packages/admin/_back/api/token-login.js
Expand Up @@ -5,8 +5,7 @@ import _ from 'lodash'
import { NotFoundError } from '~/errors'

import { validateRequestSchema } from './common/assert'
import { success, error, asyncMiddleware } from './common/reply'
import util from './common/util'
import { success, asyncMiddleware } from './common/reply'

import PairingService from '~/services/pairing'
import AuthenticationService from '~/services/authentication'
Expand All @@ -19,26 +18,6 @@ export default ({ config, db }) => {

const router = Router()

router.get(
/^\/$|^\/myself$/i,
asyncMiddleware(async (req, res) => {
return success(res)(
'Retrieved profile successfully',
_.pick(req.dbUser, ['company', 'email', 'fullName', 'id', 'picture', 'provider', 'username'])
)
})
)

router.get(
'/my-permissions/:teamId',
asyncMiddleware(async (req, res) => {
return success(res)(
"Retrieved team member's permissions successfully",
await teamSvc.getUserPermissions(req.dbUser.id, req.params.teamId)
)
})
)

router.get(
'/bot/:botId/:env',
asyncMiddleware(async (req, res) => {
Expand Down Expand Up @@ -136,20 +115,5 @@ export default ({ config, db }) => {
})
)

router.get(
'/cli',
asyncMiddleware(async (req, res) => {
validateRequestSchema(
'query',
req,
Joi.object().keys({
refresh: Joi.boolean().optional()
})
)
const { cliToken, validUntil } = await authSvc.getOrCreateCliToken(req.dbUser.id, req.query.refresh)
return success(res)('Generated CLI authentication token', { cliToken, validUntil })
})
)

return router
}
26 changes: 0 additions & 26 deletions packages/admin/_back/config/default-roles.json

This file was deleted.

0 comments on commit 34cdf69

Please sign in to comment.