import { AuthStatus } from './auth-status.model'
import { AuthUser } from './auth-user.model'
-import { ClientLocal } from '../../../../../shared'
+import { OAuthClientLocal } from '../../../../../shared'
// Do not use the barrel (dependency loop)
import { RestExtractor } from '../../shared/rest'
@Injectable()
export class AuthService {
- private static BASE_CLIENT_URL = API_URL + '/api/v1/clients/local'
+ private static BASE_CLIENT_URL = API_URL + '/api/v1/oauth-clients/local'
private static BASE_TOKEN_URL = API_URL + '/api/v1/users/token'
private static BASE_USER_INFORMATIONS_URL = API_URL + '/api/v1/users/me'
.map(this.restExtractor.extractDataGet)
.catch(res => this.restExtractor.handleError(res))
.subscribe(
- (result: ClientLocal) => {
+ (result: OAuthClientLocal) => {
this.clientId = result.client_id
this.clientSecret = result.client_secret
console.log('Client credentials loaded.')
+++ /dev/null
-import * as express from 'express'
-
-import { CONFIG } from '../../initializers'
-import { logger } from '../../helpers'
-import { database as db } from '../../initializers/database'
-import { ClientLocal } from '../../../shared'
-
-const clientsRouter = express.Router()
-
-clientsRouter.get('/local', getLocalClient)
-
-// Get the client credentials for the PeerTube front end
-function getLocalClient (req: express.Request, res: express.Response, next: express.NextFunction) {
- const serverHostname = CONFIG.WEBSERVER.HOSTNAME
- const serverPort = CONFIG.WEBSERVER.PORT
- let headerHostShouldBe = serverHostname
- if (serverPort !== 80 && serverPort !== 443) {
- headerHostShouldBe += ':' + serverPort
- }
-
- // Don't make this check if this is a test instance
- if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) {
- logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe)
- return res.type('json').status(403).end()
- }
-
- db.OAuthClient.loadFirstClient(function (err, client) {
- if (err) return next(err)
- if (!client) return next(new Error('No client available.'))
-
- const json: ClientLocal = {
- client_id: client.clientId,
- client_secret: client.clientSecret
- }
- res.json(json)
- })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- clientsRouter
-}
import { badRequest } from '../../helpers'
-import { clientsRouter } from './clients'
+import { oauthClientsRouter } from './oauth-clients'
import { configRouter } from './config'
import { podsRouter } from './pods'
import { remoteRouter } from './remote'
const apiRouter = express.Router()
-apiRouter.use('/clients', clientsRouter)
+apiRouter.use('/oauth-clients', oauthClientsRouter)
apiRouter.use('/config', configRouter)
apiRouter.use('/pods', podsRouter)
apiRouter.use('/remote', remoteRouter)
--- /dev/null
+import * as express from 'express'
+
+import { CONFIG } from '../../initializers'
+import { logger } from '../../helpers'
+import { database as db } from '../../initializers/database'
+import { OAuthClientLocal } from '../../../shared'
+
+const oauthClientsRouter = express.Router()
+
+oauthClientsRouter.get('/local', getLocalClient)
+
+// Get the client credentials for the PeerTube front end
+function getLocalClient (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const serverHostname = CONFIG.WEBSERVER.HOSTNAME
+ const serverPort = CONFIG.WEBSERVER.PORT
+ let headerHostShouldBe = serverHostname
+ if (serverPort !== 80 && serverPort !== 443) {
+ headerHostShouldBe += ':' + serverPort
+ }
+
+ // Don't make this check if this is a test instance
+ if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) {
+ logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe)
+ return res.type('json').status(403).end()
+ }
+
+ db.OAuthClient.loadFirstClient(function (err, client) {
+ if (err) return next(err)
+ if (!client) return next(new Error('No client available.'))
+
+ const json: OAuthClientLocal = {
+ client_id: client.clientId,
+ client_secret: client.clientSecret
+ }
+ res.json(json)
+ })
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+ oauthClientsRouter
+}
+++ /dev/null
-export interface ClientLocal {
- client_id: string
- client_secret: string
-}
-export * from './client-local.model'
export * from './job.model'
+export * from './oauth-client-local.model'
export * from './pod.model'
export * from './request-scheduler.model'
export * from './user-video-rate.model'
--- /dev/null
+export interface OAuthClientLocal {
+ client_id: string
+ client_secret: string
+}