Skip to content

Commit

Permalink
Merge pull request #50 from ansibleguy76/release/v3.0.4
Browse files Browse the repository at this point in the history
v3.0.4 into main
  • Loading branch information
ansibleguy76 authored Jun 9, 2022
2 parents 4664262 + ca08c57 commit 162117e
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 28 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.4] - 2022-06-09

### Fixed

- Forgot fs-extra in package

### Added

- Added 'ansibleforms_user' as object to extravars

## [3.0.3] - 2022-06-02

### Changed
Expand Down Expand Up @@ -274,7 +284,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/3.0.3...HEAD
[Unreleased]: https://github.com/ansibleguy76/ansibleforms/compare/3.0.4...HEAD

[3.0.4]: https://github.com/ansibleguy76/ansibleforms/compare/3.0.3...3.0.4

[3.0.3]: https://github.com/ansibleguy76/ansibleforms/compare/3.0.2...3.0.3

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 = 30003
ext.version_name = "3.0.3"
ext.version_code = 030004
ext.version_name = "3.0.4"
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": "3.0.3",
"version": "3.0.4",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/Credentials.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:dataList="credentialList"
:labels="['Name','User','Host']"
:columns="['name','user','host']"
:filters="['name','user']"
:filters="['name','user','host']"
identifier="id"
:actions="[{name:'select',title:'edit credential',icon:'pencil-alt',color:'has-text-warning'},{name:'delete',title:'delete credential',icon:'times',color:'has-text-danger'}]"
:currentItem="credentialItem"
Expand Down
3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansible_forms",
"version": "3.0.3",
"version": "3.0.4",
"repository": {
"type": "git",
"url": "git://github.com/ansibleguy76/ansibleforms.git"
Expand Down Expand Up @@ -41,6 +41,7 @@
"mssql":"~8.1.2",
"mongodb":"~4.6.0",
"pg":"~8.7.3",
"fs-extra":"~10.1.0",
"node-cache":"~5.1.2",
"ldap-authentication": "~2.2.9",
"ldapjs": "~2.3.2",
Expand Down
6 changes: 4 additions & 2 deletions server/src/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ passport.use(
logger.info(JSON.stringify(result))
user.username = result.sAMAccountName
user.type = 'ldap'
user.roles = User.getRoles(user,result)
user.groups = User.getGroups(user,result)
user.roles = User.getRoles(user.groups,user)
logger.info("ldap login is ok => " + user.username)
return user
})
Expand All @@ -39,7 +40,8 @@ passport.use(
user.username = result.user.username
user.id = result.user.id
user.type = 'local'
user.roles = User.getRoles(user,result.user.groups)
user.groups = User.getGroups(user,result.user.groups)
user.roles = User.getRoles(user.groups,user)
logger.info("local login is ok => " + user.username)
return user
})
Expand Down
1 change: 1 addition & 0 deletions server/src/controllers/job.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ exports.launch = async function(req, res) {
var extravars = req.body.extravars
var creds = req.body.credentials
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,""))
})
Expand Down
48 changes: 29 additions & 19 deletions server/src/models/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,26 @@ User.checkToken = function (username,username_type,refresh_token) {
}
})
};
User.getRoles = function(user,groupObj){
User.getRoles = function(groups,user){
var roles = ["public"]
var forms=undefined
try{
forms = Form.load()
}catch(e){
logger.error(e)
return roles
}
groups.forEach(function(group){
// add all the roles that match the group
forms.roles.forEach(function(role){
if(role.groups.includes(group)){
roles.push(role.name)
}
})
})
return roles
}
User.getGroups = function(user,groupObj){
var groupMatch=""
var group=""
var groups = []
Expand All @@ -122,44 +140,36 @@ User.getRoles = function(user,groupObj){
forms = Form.load()
}catch(e){
logger.error(e)
return roles
return groups
}
// ldap type
if(user.type=="ldap"){
if(groupObj.memberOf){
// get the memberOf field, force to array
groups = [].concat(groupObj.memberOf)
var ldapgroups = [].concat(groupObj.memberOf)
// loop ldap groups
groups.forEach(function(v,i,a){
ldapgroups.forEach(function(v,i,a){
// grab groupname part
var groupMatch=v.match("^[cCnN]{2}=([^,]*)")
if(groupMatch.length>0){
// prefix with ldap
group="ldap/" + groupMatch[1]
// add all the roles that match the group
forms.roles.forEach(function(v,i,a){
if(v.groups.includes(group)){
roles.push(v.name)
}
})
groups.push(group)
}
})
}
return roles
return groups
}else if(user.type="local"){
groups = groupObj.split(",")
groups.forEach(function(v,i,a){
var localgroups = groupObj.split(",")
localgroups.forEach(function(v,i,a){
group='local/' + v
// add all the roles that match the group
forms.roles.forEach(function(v,i,a){
if(v.groups.includes(group)){
roles.push(v.name)
}
})
groups.push(group)
})
return roles
return groups
}else{
return roles
return groups
}
}
User.checkLdap = function(username,password){
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": "3.0.3",
"version": "3.0.4",
"title": "AnsibleForms",
"contact": {
"email": "[email protected]"
Expand Down

0 comments on commit 162117e

Please sign in to comment.