Skip to content

Commit

Permalink
Merge pull request #87 from ansibleguy76/release/v4.0.11
Browse files Browse the repository at this point in the history
v4.0.11 into main
  • Loading branch information
ansibleguy76 authored Jun 8, 2023
2 parents 12350dc + 564b3b7 commit 992dd8c
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 43 deletions.
31 changes: 21 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.11] - 2023-06-08

### Added

- Allow users in roles

### Fixed

- app crash on bad rest body
- errors were not shown in output

## [4.0.10] - 2023-05-23

### Fixed
Expand Down Expand Up @@ -41,7 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- new function fn.fnCidr // core implementation of ip.subnet() <https://www.npmjs.com/package/ip>
- new function fn.fnTime // core implementation of dayjs() <https://day.js.org>
- new function fn.fnTime // core implementation of dayjs() <https://day.js.org>
- background image on login screen (that you can overwrite)

## [4.0.7] - 2023-05-01
Expand All @@ -62,7 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Allow awx connection with username and password
- Added about me for
- Added about me for
- Added new env var with regex to filter job output

### Changed
Expand Down Expand Up @@ -92,7 +103,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add server fn.fnSsh function
- Showing env.variables in the settings
- Showing known_hosts and allow removal
- Added limit property for ansible playbooks
- Added limit property for ansible playbooks

### Changed

Expand Down Expand Up @@ -341,10 +352,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- insertMarker and deleteMarker (to mark deleted or new records)
- allowDelete and allowInsert (to allow insert/delete)
- readonlyField
With this table feature you can now load existing data and use table to modify it.
The allowInsert set to false will focus on modification only.
The deleteMarker set to value of choice, will allow you to use ansible `absent` for deleted records.
Read the wiki for more details.
With this table feature you can now load existing data and use table to modify it.
The allowInsert set to false will focus on modification only.
The deleteMarker set to value of choice, will allow you to use ansible `absent` for deleted records.
Read the wiki for more details.

### Fixed

Expand Down Expand Up @@ -513,7 +524,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow change password for current local user
- Start tracking versions

[Unreleased]: https://github.com/ansibleguy76/ansibleforms/compare/4.0.10...HEAD
[Unreleased]: https://github.com/ansibleguy76/ansibleforms/compare/4.0.11...HEAD

[4.0.11]: https://github.com/ansibleguy76/ansibleforms/compare/4.0.10...4.0.11

[4.0.10]: https://github.com/ansibleguy76/ansibleforms/compare/4.0.9...4.0.10

Expand Down Expand Up @@ -567,6 +580,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[2.1.6]: https://github.com/ansibleguy76/ansibleforms/compare/2.1.5...2.1.6

[2.1.6]: https://github.com/ansibleguy76/ansibleforms/compare/2.1.5...2.1.6

[2.1.5]: https://github.com/ansibleguy76/ansibleforms/compare/2.1.4...2.1.5
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Expand Down
4 changes: 2 additions & 2 deletions app_versions.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ext.version_code = 40010
ext.version_name = "4.0.10"
ext.version_code = 40011
ext.version_name = "4.0.11"
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansible_forms_vue",
"version": "4.0.10",
"version": "4.0.11",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansible_forms",
"version": "4.0.10",
"version": "4.0.11",
"repository": {
"type": "git",
"url": "git://github.com/ansibleguy76/ansibleforms.git"
Expand Down
26 changes: 22 additions & 4 deletions server/schema/forms_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@
"items": {
"type": "object",
"required": [
"name",
"groups"
"name"
],
"anyOf": [
{
"required": [
"groups"
]
},{
"required": [
"users"
]
}
],
"properties": {
"name": {
"$id": "/role",
Expand All @@ -66,9 +76,17 @@
"default": "",
"pattern": "(\\blocal\\b|\\bldap\\b|\\bazuread\\b)\\/.+"
}
}
},
"users": {
"type": "array",
"items": {
"type": "string",
"default": "",
"pattern": "(\\blocal\\b|\\bldap\\b|\\bazuread\\b)\\/.+"
}
}
},
"additionalProperties": false
"additionalProperties": true
}
},
"constants":{
Expand Down
6 changes: 5 additions & 1 deletion server/schema/help.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@
objectLink: forms/role
short: Roles
description: |
The roles provide RBAC. Each role has a name and 1 or more groups (local, ldap or azuread). The `admin` and `public` rol is mandatory.
The roles provide RBAC. Each role has a name and 1 or more groups (local, ldap or azuread). The `admin` and `public` rol is mandatory.
Since version 4.0.11 you can also add users (local, ldap or azuread)
examples:
- name: Roles
code: |
Expand All @@ -409,6 +410,9 @@
- name: demo
groups:
- local/demo
- name: usersonly
users:
- local/myuser
- name: public # is mandatory
groups: []
- name: constants
Expand Down
59 changes: 38 additions & 21 deletions server/src/controllers/job.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports.getJob = function(req, res) {

};
exports.findAllJobs = function(req, res) {
var user = req.user.user
var user = req?.user?.user || {}
var records = req.query.records || 500
Job.findAll(user,records)
.then((jobs)=>{res.json(new RestResult("success","jobs found",jobs,""))})
Expand Down Expand Up @@ -94,19 +94,23 @@ exports.launch = async function(req, res) {
res.json(new RestResult("error","no data was sent","",""));
}else{
// get the form data
var form = req.body.formName;
var form = req.body.formName || "";
var extravars = req.body.extravars || {}
var creds = req.body.credentials || {}
var awxCreds = req.body.awxCredentials || {}
for (const [key, value] of Object.entries(awxCreds)) {
creds["awx___"+key]=value
}
var user = req.user.user
var user = req?.user?.user || {}
extravars.ansibleforms_user = user
Job.launch(form,null,user,creds,extravars,null,function(job){
res.json(new RestResult("success","succesfully launched form",job,""))
})
.catch((err)=>{res.json(new RestResult("success","failed to launch form",null,err.toString))})
try{
await Job.launch(form,null,user,creds,extravars,null,function(job){
res.json(new RestResult("success","succesfully launched form",job,""))
})
}catch(err){
logger.error(err.toString())
res.json(new RestResult("success","failed to launch form",null,err.toString()))
}
}
};
exports.relaunchJob = async function(req, res) {
Expand All @@ -117,11 +121,15 @@ exports.relaunchJob = async function(req, res) {
res.json(new RestResult("error","You must provide a jobid","",""));
return false
}
var user = req.user.user
Job.relaunch(user,jobid,(job)=>{
res.json(new RestResult("success",`Job has been relaunched with job id ${job.id}`,"",""))
})
.catch((err)=>{ res.json(new RestResult("error",`Failed to relaunch : ${err.toString()}`,"","")) })
var user = req?.user?.user || {}
try{
await Job.relaunch(user,jobid,(job)=>{
res.json(new RestResult("success",`Job has been relaunched with job id ${job.id}`,"",""))
})
}catch(err){
logger.error(err.toString())
res.json(new RestResult("error",`Failed to relaunch : ${err.toString()}`,"",""))
}
};
exports.approveJob = async function(req, res) {

Expand All @@ -131,11 +139,15 @@ exports.approveJob = async function(req, res) {
res.json(new RestResult("error","You must provide a jobid","",""));
return false
}
var user = req.user.user
Job.approve(user,jobid,(job)=>{
res.json(new RestResult("success",`Job ${jobid} has been approved`,"",""))
})
.catch((err)=>{res.json(new RestResult("error",`Failed to approve : ${err.toString()}`,"",""))})
var user = req?.user?.user || {}
try{
await Job.approve(user,jobid,(job)=>{
res.json(new RestResult("success",`Job ${jobid} has been approved`,"",""))
})
}catch(err){
logger.error(err.toString())
res.json(new RestResult("error",`Failed to approve : ${err.toString()}`,"",""))
}
};
exports.rejectJob = async function(req, res) {

Expand All @@ -145,8 +157,13 @@ exports.rejectJob = async function(req, res) {
res.json(new RestResult("error","You must provide a jobid","",""));
return false
}
var user = req.user.user
Job.reject(user,jobid)
.then(()=>{res.json(new RestResult("success",`Job ${jobid} has been rejected`,"",""))})
.catch((err)=>{res.json(new RestResult("error",`Failed to reject : ${err.toString()}`,"",""))})
var user = req?.user?.user || {}
try{
await Job.reject(user,jobid)
res.json(new RestResult("success",`Job ${jobid} has been rejected`,"",""))
}catch(err){
logger.error(err.toString())
res.json(new RestResult("error",`Failed to reject : ${err.toString()}`,"",""))
}

};
2 changes: 1 addition & 1 deletion server/src/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ Helpers.formatOutput = (records,asText)=>{
if(filterOutput){
line=line.replace(/class='/g,"class='low ")
}
lineoutput.push(line)
}
lineoutput.push(line)
}) // end line loop
// we add a timestamp to the record
// we push it in the intermediate output array
Expand Down
11 changes: 10 additions & 1 deletion server/src/models/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ User.checkToken = function (username,username_type,refresh_token) {
User.getRoles = function(groups,user){
var roles = ["public"]
var forms=undefined
var full_username = `${user.type}/${user.username}`
try{
forms = Form.load()
}catch(e){
Expand All @@ -124,11 +125,19 @@ User.getRoles = function(groups,user){
groups.forEach(function(group){
// add all the roles that match the group
forms.roles.forEach(function(role){
if(role.groups.includes(group)){
if(role.groups && role.groups.includes(group)){
roles.push(role.name)
}
})
})

// add all the roles that match the user
forms.roles.forEach(function(role){
if(role.users && role.users.includes(full_username)){
roles.push(role.name)
}
})

return roles
}
User.getGroups = function(user,groupObj){
Expand Down
2 changes: 1 addition & 1 deletion server/src/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"description": "This is the swagger interface for AnsibleForms.\r\nUse the `/auth/login` api with basic authentication to obtain a JWT token.\r\nThen use the access token, prefixed with the word '**Bearer**' to use all other api's.\r\nNote that the access token is limited in time. You can then either login again and get a new set of tokens or use the `/token` api and the refresh token to obtain a new set (preferred).",
"version": "4.0.10",
"version": "4.0.11",
"title": "AnsibleForms",
"contact": {
"email": "[email protected]"
Expand Down

0 comments on commit 992dd8c

Please sign in to comment.