Commentable plug-in with Spring Security LDAP - grails-plugin

I'm trying to get the commentable plug-in running with the spring security framework ldap plugin from Burt Beckwith.
I found a similar problem here.
The only difference seems to be that I'm using LDAP and the LDAP user details don't have an id, or I'm not seeing it.
I've tried setting the grails.commentable.poster.evaluator to
{com.companyname.sec.User.get(org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.id)}
and also to
{com.companyname.sec.User.get(principal.id)}
Both of these were suggested in the other issue I referenced above. What I get is the error below:
groovy.lang.MissingPropertyException: No such property: id for class: org.springframework.security.ldap.userdetails.LdapUserDetailsImpl
Possible solutions: dn
This seems to suggest using the dn field, but since that's a string, and the id is a Long, I don't think that's the right option. So, is there a way to configure the grails.commentable.poster.evaluator to get these two plug-ins to work together, or do I need to modify one of them to get a compatible type (i.e. change the commentable plug-in to use a String, and then grab the username from the LDAP user details.)?

Not using the commentable but the spring-security-ldap plugin.
For me this really simple copy&paste solution worked:
Solution on Grails Jira by Burt

Use
{com.companyname.sec.User.findByUsername(principal.username)}
or
{com.companyname.sec.User.findByUsername(org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.username)}

That gives me the following error:
org.grails.comments.CommentException: No [grails.commentable.poster.evaluator] setting defined or the evaluator doesn't evaluate to an entity. Please define the evaluator correctly in grails-app/conf/Config.groovy or ensure commenting is secured via your security rules
I read that to mean there is no findByUsername method. So, were you suggesting I create that method in order to get at an id value? And I assume correspondingly, that means I need to insert the ldap users into the database in order to generate an id.

Related

Create issue : Test link integration with jira

I've integrated Testlink with Jira using below xml
<issuetracker>
<username>xyz</username>
<password>#123</password>
<uribase>abc.net/projects/KEY/</uribase>
<uriapi>abc.net/rest/api/latest/</uriapi>
<uriview>abc.net/browse/</uriview>
<projectkey>KEY</projectkey>
<issuetype>1</issuetype>
</issuetracker>
I am able to link existing jira issue in to test link.
But create issue window contains Version field which would not alow me to enter any value or not giving any suggestion as displayed in below image.
I've tried to create version in jira but it doesn't work.
So,
What value i should enter/configure for version field ?
What is use of <issuetype>1</issuetype> ? can we provide any other value?
How to link new field on create Issue window?
4.Version is mismatched with jira field Versions.
I'm not sure which version of JIRA REST API you are using but the tutorial for the v2 says:
Just like everyone else in the real world, we're faced with time and resource constraints. Supporting two serialisation formats requires more time than just a single one. Hence, for our initial release of the JIRA REST API, we decided to provide "more stuff in JSON" rather than "less stuff in JSON and XML".
So I'm not sure about the XML support. I have no experience with Testlink, but I guess it's using some kind of serialiser at the back end.
If you check the Create issue endpoint, there is no version field. I guess it will be the versions field instead. In JIRA projects can have multiple versions. You can get a list of versions from the Get project eversions endpoint.
Issue type is an ID of issue type you want to use for your issue. You can get a list of project specific issue types from the Get issue all types
endpoint.
I'm not sure about this
Check the first point
This version field is empty because you have not specified any version for your project in JIRA. In my case it was Fix version in JIRA. Currently the rest API is getting an empty list of versions. You can try
curl -X GET http://example.com/rest/api/2/project/KEY/versions
-H 'authorization: Basic dtgzkisVlbyhsuYWhtYijdsdidjjsidDkw'
This will give you an empty list.
Once you set FixVersion in for your project in JIRA, this API will return the list of available versions for your project and the Version field will be populated with those versions.
PS: use your own authorization headers. You can use [Postman][1] for this purpose.

Adding recipient Groups to a CiviCRM Mailing via REST.. how?

I have been able so far to create a new civi Mailing object and populate it, but confusingly I can't see a parameter in that to specify the mail destination group.
For context, I am dealing with Civi using pure REST api from a remote server. I have a solution to getting a custom template onto the server; the new problem is setting a schedule and delivery group, and initiating the send. I am using the python-civicrm library from github as the intermediary on the client.
I presume send happens as a result of setting the schedule -- i.e. I don't need an API call to say 'send mailing'? Is setting 'sheduled date' == 'now' safe or should I set a date of 'now + 1min' or similar?
So that leaves setting the delivery group. We already have groups defined in the DB, and I want to specify the group by name (and preferably be able to verify in advance that a group name is a valid destination, perhaps by doing a group name -> id lookup).
I think there might be a parameter to Mailing create 'groups' which can have keys 'include' and 'exclude'; at least, that's what the web form seems to do. However it's not mentioned in the REST api implementation.
Can anyone offer pointers?
I think you will find all you need in the following link :
Example of api call that is using the group include/exclude : https://gist.github.com/xurizaemon/6775471
Discussion about implementing mailing as an api - http://forum.civicrm.org/index.php?topic=24075.0
Otherwise, if it doesn't work, i suggest that you :
help adding this api in the CiviCRM Core - you could have some help on this on irc #civicrm (and have a look at https://issues.civicrm.org/jira/browse/CRM-11023)
OR create an extension with the api you need. It will be automatically available for REST. If you haven't created an extension yet, i suggest you go to the page http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension. It's quite straightforward with civix installed.
The table you need to check in the database is civicrm_mailing_group
To confirm, the problem was that (a) I needed to use groups[include]=array(ids) as mentioned by samuelsov, but also (b) I needed to use the json={...} form of request through REST, because the HTTP params syntax doesn't support nested data.

Ldap Domain Name validator

I want to create a validator for dn of an ldap, I mean that if I get as input a string from user, my regex, program, library (whatever works) can tell me if string inserted is a ldap dn or not, can You help me??
Maybe I asked in the wrong place, however (for those who will make a similar search) I post the answer I found from another part: https://serverfault.com/questions/549961/ldap-distinguished-name-validator
LDAP C API has a function for DN parsing that is called ldap_explode_dn. There are also many bindings for different languages (PHP, python, etc.). I suggest you consider using this API as a DN validation tool.

Kohana 3 auth username as number

I want to use numbers as username in Kohana Auth. For example, username 100001?
While adding new user Kohana returns me error: ORM_Validation_Exception [ 0 ]: Failed to validate array
Is is possible to user numbers as username in Kohana?
EDIT: This answer looks simpler and better than mine, but try to understand it at all.
You need to extend User Model, I'll help you using auth with the ORM driver.
Steps to extend User Model:
If you didn't yet, configure Auth module to use orm and create a database table with the fields you want. Here is a good example of how to doing it (It's an old tutorial using ko3.1 but you can still learn from it). PS.: you can have any columns at the 'users' table and you don't need to have the 'username' column if you do not want.
Open and read carefully this file: MODULES/orm/classes/model/auth/user.php (It's self documented and I hope you understand it. If not, stop reading this answer here and read the kohana docs. Some shortcuts: Auth - Kohana User Guide, Auth (orm) methods, addons:auth
Copy the file (don't edit the original) to APPPATH/classes/model/auth/user.php and edit it how you want. Some functions that you may like to edit are: rules, filters and unique_key (<- useful). Be creative, you also can add custom functions.
Test and change whatever else needed.
You can change the login method to works as you like. You can set login by e-mail, make a custom validation method or parse values before saving in the database (see public function filters()). This is helpful for whatever you try to do with auth module using ORM... But... if you really don't want to use ORM, you can build your own driver, learn how.
I made this some time ago in kohana 3.2 but I think you won't get problems with 3.3. If you still have questions, this question on kohana forum may help.

Jira SOAP API custom field

Hi I'm am trying to get the list of issues from a JIRA server using the SOAP API provided by JIRA.
I'm trying to filter the issues based on a custom field (and latter I will want to set that custom field).
If I get the list of issue it returns the custom fields for those issues along with them (I get customfieldId, key, values for each custom field) and I can get the custom field with getCustomFields methods provided by the API (to look for the ID of the field with a given name).
The issue I have is that if I login with an account that is not an admin (using the API) I can't call the getCustomFields method (it throws an exception saying I have to be an admin to do that).
My question is: Is there any other way to know which is the ID of the custom field I desire that can be done using a normal user account?
Also if you know how to set a custom field for an issue, it would also be very helpful :) (I would also like to be able to do it with a regular user account).
You have to be an admin to get a list of custom fields. Any 'normal' account can act on the custom fields via the API provided the user knows the customfield ID.
You can set the value of a custom field too, even with a 'normal' account. Again, the user needs the appropriate permissions to do this. Example provided here.
More here and here.
You can also use getFieldsForEdit(token, issueKey), which will return RemoteField[] for all fields available for edit on that issue (even if it has not yet been defined on the issue). It does not require admin permissions, but because it has the word "Edit" in the method, it does require that you have permission to edit the issue (which means, e.g., if the issue is status=Closed, it will raise an exception unless you allow editing closed issues. Unfortunately, I have yet to find a way to retrieve the RemoteField[] list (in order to map id to name), so getCustomFields() and getFieldsForEdit() appear to be the only options.
Have you tried getting a list of issues from the project, picking one, zeroing out the data, and using that as a template? That might work.
SOAP is being deprecated in favor of the REST API, which also has a better method to get this information