Commit 83d3f158 authored by Kyriakos Barbounakis's avatar Kyriakos Barbounakis

Merge branch 'cli-update' into 'master'

Updates cli by adding commands for listing scopes and users

See merge request !3
parents ed7fbffa bb2a07bb
......@@ -120,7 +120,7 @@ Run docker container console
Get list of client applications
npm run cli -- list
npm run cli list clients
...
client_id name client_secret redirect_uri grant_type
......@@ -382,9 +382,9 @@ _settings.auth.client_secret_
Defines the client secret of OAuth2 Server application
Important note: Execute
Important Note: Execute
npm run cli -- list
npm run cli list clients
to get client_id and client_secret of OAuth2 Server Application
......@@ -394,6 +394,8 @@ to get client_id and client_secret of OAuth2 Server Application
7444341691607290 OAuth2 Server Application ufpk6pbcUS9AnuUUUAmxAghXQQdHvpor http://localhost:3000/auth/callback code
... ... ... ... code,token
Universis auth server generates by default new clients for the core applications of Universis project.
**adapterTypes**
Defines an array of available MOST Web Framework adapter types for this application. These adapter types are going to be used for connection with application data storage.
......@@ -486,14 +488,39 @@ Commands:
--password Sets user password [default: false]
cli list
Lists all client applications
cli list clients
Lists all client applications
Options:
--version Show version number [boolean]
--help Show help [boolean]
--dev enables development mode [default: false]
--filter defines query filter [default: null]
--top defines query top option [default: 25]
--skip defines query skip option [default: 0]
cli list scopes
Lists all authorization scopes
Options:
--version Show version number [boolean]
--help Show help [boolean]
--dev enables development mode [default: false]
cli list users
Lists users
Options:
--version Show version number [boolean]
--help Show help [boolean]
--dev enables development mode [default: false]
--filter defines query filter [default: null]
--top defines query top option [default: 25]
--skip defines query skip option [default: 0]
cli drop <command>
......@@ -501,13 +528,18 @@ Commands:
cli drop client <client_id>
Drops a client application
Options:
--version Show version number [boolean]
--help Show help [boolean]
--dev Enables development mode [default: false]
Drops a client application
Options:
--version Show version number [boolean]
--help Show help [boolean]
--dev Enables development mode [default: false]
**Important Note**: If you are going to add options e.g. list only the first 10 clients we should pass arguments with a double dash before e.g.
npm run cli list clients -- --top=10
The special option -- is used by getopt to delimit the end of the options. npm will pass all the arguments after the -- directly to cli script.
#### Nginx Configuration
......@@ -534,7 +566,7 @@ If you are using Nginx as web server create a configuration file for Student Por
}
}
Important Note: The default port of SIS OAuth2 Server is 3000. If you want to change this port
Important Note: The default port of Universis OAuth2 Server is 3000. If you want to change this port
you need to define PORT environment variable in application startup script (See PM2 Process Manager documentation on how to define environment variables)
......@@ -587,4 +619,4 @@ Important Note: Group model must be set to sealed (by setting DataModel.sealed a
Important Note: UserCredential model must be set to sealed (by setting DataModel.sealed attribute in config/models/UserCredential.json schema) in order to prevent automatic model upgrade
*4. Set database adapter connection properties*
\ No newline at end of file
*4. Set database adapter connection properties*
{
"name": "universis-auth",
"version": "2.2.1",
"description": "MOST Web Framework OAuth2 Server Module",
"version": "2.2.2",
"description": "Universis Experimental OAuth2 Server",
"main": "index",
"scripts": {
"start": "node bin/www",
......@@ -12,7 +12,7 @@
},
"repository": {
"type": "git",
"url": "https://gitlab.themost.io/kbarbounakis/themost-auth.git"
"url": "https://gitlab.com/universis/universis-auth.git"
},
"keywords": [
"universis",
......@@ -23,13 +23,13 @@
"peerDependencies": {},
"dependencies": {
"@themost/cli": "^2.1.9",
"@themost/common": "^2.1.5",
"@themost/data": "^2.2.1",
"@themost/common": "^2.1.6",
"@themost/data": "^2.2.4",
"@themost/mailer": "^2.1.1",
"@themost/mssql": "^2.1.3",
"@themost/mysql": "^2.1.2",
"@themost/sqlite": "^2.1.2",
"@themost/web": "^2.2.1",
"@themost/mysql": "^2.1.3",
"@themost/sqlite": "^2.1.5",
"@themost/web": "^2.2.5",
"angular": "^1.5.8",
"angular-animate": "^1.5.8",
"angular-aria": "^1.5.8",
......
......@@ -20,7 +20,7 @@ export function builder(yargs) {
describe: 'Sets user description e.g. John Doe'
}).option('password', {
default: false,
describe: 'Sets user password'
describe: 'Prompt for user password'
});
}
......@@ -91,4 +91,4 @@ export function handler(argv) {
process.exit(-2);
}
});
}
\ No newline at end of file
}
import 'console.table';
import {finalize, getApplication} from "../utils";
import path from 'path';
export const command = 'list <command>';
export const command = 'list';
export const desc = 'Lists all client applications';
export const desc = 'Returns a list of objects (client, user, scope etc)';
export function builder(yargs) {
return yargs.option('dev', {
default: false,
describe: 'enables development mode'
});
return yargs.commandDir(path.resolve(__dirname, 'list_commands'));
}
export function handler(argv) {
if (argv.dev) {
process.env.NODE_ENV = 'development'
}
const app = getApplication();
app.execute(async (context)=> {
try {
// get client
let clients = await context.model('AuthClient').asQueryable().silent().getAllItems();
// print list
console.table(clients);
// finalize context
await finalize(context);
// exit
process.exit();
}
catch(err) {
// finalize context
await finalize(context);
// log error
console.error(err);
// exit
process.exit(-2);
}
});
export function handler() {
}
import 'console.table';
import {finalize, getApplication} from "../../utils";
export const command = 'clients';
export const desc = 'Lists all client applications';
export function builder(yargs) {
return yargs.option('dev', {
default: false,
describe: 'enables development mode'
}).option('filter', {
default: null,
describe: 'defines query filter'
}).option('top', {
default: 25,
describe: 'defines query top option'
}).option('skip', {
default: 0,
describe: 'defines query skip option'
});
}
export function handler(argv) {
if (argv.dev) {
process.env.NODE_ENV = 'development'
}
const app = getApplication();
app.execute(async (context)=> {
try {
// get query options
let query = Object.assign({ }, {
$filter: argv.filter,
$top: argv.top,
$skip: argv.skip,
$count: true
});
// get data queryable
let getClients = await context.model('AuthClient').filter(query);
// get client
let clients = await getClients.expand('scopes').silent().getList();
clients.value.forEach( client => {
client.scopes = client.scopes.map ( x => x.name).join(',');
});
if (clients.value.length) {
// print list
console.table(clients.value);
}
// print footer
console.log(`(Total records): ${clients.total}`);
// finalize context
await finalize(context);
// exit
process.exit();
}
catch(err) {
// finalize context
await finalize(context);
// log error
console.error(err);
// exit
process.exit(-2);
}
});
}
import 'console.table';
import {finalize, getApplication} from "../../utils";
export const command = 'scopes';
export const desc = 'Lists all authorization scopes';
export function builder(yargs) {
return yargs.option('dev', {
default: false,
describe: 'enables development mode'
});
}
export function handler(argv) {
if (argv.dev) {
process.env.NODE_ENV = 'development'
}
const app = getApplication();
app.execute(async (context)=> {
try {
// get scopes
let scopes = await context.model('AuthScope').asQueryable().silent().getAllItems();
if (scopes.length > 0) {
// print list
console.table(scopes);
}
// print footer
console.log(`(Total records): ${scopes.length}`);
// finalize context
await finalize(context);
// exit
process.exit();
}
catch(err) {
// finalize context
await finalize(context);
// log error
console.error(err);
// exit
process.exit(-2);
}
});
}
import 'console.table';
import {finalize, getApplication} from "../../utils";
export const command = 'users';
export const desc = 'Lists users';
export function builder(yargs) {
return yargs.option('dev', {
default: false,
describe: 'enables development mode'
}).option('filter', {
default: null,
describe: 'defines query filter'
}).option('top', {
default: 25,
describe: 'defines query top option'
}).option('skip', {
default: 0,
describe: 'defines query skip option'
});
}
export function handler(argv) {
if (argv.dev) {
process.env.NODE_ENV = 'development'
}
const app = getApplication();
app.execute(async (context)=> {
try {
// get query options
let query = Object.assign({ }, {
$filter: argv.filter,
$top: argv.top,
$skip: argv.skip,
$count: true
});
// get data queryable
let getUsers = await context.model('User').filter(query);
// get users
let users = await getUsers.select('name', 'description', 'enabled', 'dateCreated').silent().getList();
// print list
if (users.value.length>0) {
console.table(users.value);
}
// print footer
console.log(`(Total records): ${users.total}`);
// finalize context
await finalize(context);
// exit
process.exit();
}
catch(err) {
// finalize context
await finalize(context);
// log error
console.error(err);
// exit
process.exit(-2);
}
});
}
......@@ -125,14 +125,14 @@
]
},
{
"name": "Dashboard Application",
"redirect_uri": "http://localhost:7003/auth/callback",
"name": "Registrar Application",
"redirect_uri": "http://localhost:4200/auth/callback",
"grant_type": "code,token",
"scopes":[
{
"name": "dashboard"
"name": "registrar"
}
]
}
]
}
\ No newline at end of file
}
......@@ -86,9 +86,9 @@
"url": "urn:universis:v1:scopes:teachers"
},
{
"name":"dashboard",
"name":"registrar",
"description":"View and manage student information system data",
"url": "urn:universis:v1:scopes:dashboard"
"url": "urn:universis:v1:scopes:registrar"
}
]
}
\ No newline at end of file
}
<%# { "layout":"./../shared/master.html.ejs", "title":"Login" } %>
<% layout('./../shared/master') %>
<div class="row justify-content-center">
<div class="col-md-9">
<div class="card-group">
......@@ -16,4 +16,4 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
<%# { "layout":"./../shared/master.html.ejs", "title":"Login" } %>
<% layout('./../shared/master') %>
<div class="row justify-content-center" ng-controller="LoginController as login">
<div class="col-md-9">
<div class="card-group">
......@@ -37,4 +37,4 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
<%# { "layout":"./../shared/master.html.ejs", "title":"Login Status" } %>
<% layout('./../shared/master') %>
<div class="row justify-content-center">
<div class="col-md-9">
<div class="card-group">
......@@ -18,4 +18,4 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment