Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
In my config.groovy I have some code for LDAP authentication using springsecurity plugin.
grails.plugin.springsecurity.ldap.context.managerDn = CN=user,OU=Accounts,OU=Users,DC=organization,DC=com'
grails.plugin.springsecurity.ldap.context.managerPassword = 'password'
grails.plugin.springsecurity.ldap.context.server = 'ldap://ldapserver.com:389/'
grails.plugin.springsecurity.ldap.authorities.ignorePartialResultException = true // typically needed for Active Directory
grails.plugin.springsecurity.ldap.search.base = 'DC=organization,DC=com'
grails.plugin.springsecurity.ldap.search.filter="(&(sAMAccountName={0})(|(memberOf=...)(memberOf=...)(memberOf=...)))"
grails.plugin.springsecurity.ldap.search.searchSubtree = true
grails.plugin.springsecurity.ldap.auth.hideUserNotFoundExceptions = false
grails.plugin.springsecurity.providerNames=['ldapAuthProvider']
grails.plugin.springsecurity.securityConfigType = "Annotation"
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/**': ['isFullyAuthenticated()']
]
It works fine but now I need to display logged username on main page and whichever user is logged, doing some actions. How I can do that?
have you tried <sec:username/>?
username
Displays the value of the UserDetails username field if logged in.
<sec:ifLoggedIn>
Welcome Back <sec:username/>!
</sec:ifLoggedIn>
<sec:ifNotLoggedIn>
<g:link controller='login' action='auth'>Login</g:link>
</sec:ifNotLoggedIn>
I you want to get the username in a service or controller, you should use:
def springSecurityService
def someActionOrMethod(){
println springSecurityService.currentUser.username
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
If yes, can you point me to some resources on how to accomplish this task? Or share your expertise on this topic?
1 Get your Firebase Api key
2 Check your JWT
def firebase_verification(token)
url = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=#{ENV['FIREBASE_API_KEY']}"
firebase_verification_call = HTTParty.post(url, headers: { 'Content-Type' => 'application/json' }, body: { 'idToken' => token }.to_json )
if firebase_verification_call.response.code == "200"
firebase_infos = firebase_verification_call.parsed_response
else
raise CustomError
end
end
3 Create the user
def firebase_login(token)
firebase_infos = firebase_verification(token)
raise CustomError if uid != firebase_infos['users'][0]['localId']
user = find_by(digits_id: firebase_infos['users'][0]['localId'])
if user.nil?
user = new
user.email = ''
user.password = Devise.friendly_token
user.digits_id = firebase_infos['users'][0]['localId']
user.digits_created_at = firebase_infos['users'][0]['createdAt']
end
user.phone_number = firebase_infos['users'][0]['phoneNumber']
user.access_token = token
user.save
user
end
for more details check this out
I believe that you can. Basically you are going to use firebase auth for authentication and your ruby app will get the authentication token and check if it is valid. I am not sure if there is an active ruby library to install for firebase (its always easier with a good lib) but you can use Firebase rest api to check for the token.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
I need to integrate servicenow with slack which helps to send high and critical P1 alerts to a slack channel.
I am looking for possibilities that can be done to get the serviceNow integrated with slack.
Please suggest.
You should create a Business Rule in ServiceNow on insert/update.
Condition:
Priority = 1 or Priority ChangesTo 1
Advanced/Script:
var request = new sn_ws.RESTMessageV2('SLACK_EndpointURL', 'POST');
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
//OR METHOD # request.setEndpoint('SLACK_EndpointURL');
// Your message
var reqBody = '{\"text\":\"This is a line of text.\nAnd this is another one.\"}';
request.setRequestBody(reqBody);
var response = request.execute();
var responseBody = response.getBody();
//See response in System Logs # gs.log(responseBody);
There are multiple ways to integrate ServiceNow and Slack. But a simple and straight-forward approach for your case would be to create an Incoming WebHook in Slack which provides a URL and all you need to do from your ServiceNow instance is to post JSON to that URL.
You can find more details about creating and customizing Slack webhooks here: https://api.slack.com/incoming-webhooks
You could use a BR to trigger with the desired conditions. This function posts our messages to Slack. The endpoint is the inbound webhook address created in Slack:
function postMessage(inPayload, inEndpoint, inTimeout) {
var sResponseBody = '', nResponseCode = 0, sResponseMessage = '', sResponseEndpoint = '', sResponseHeaders = [];
var rest = new sn_ws.RESTMessageV2();
rest.setEndpoint(inEndpoint);
rest.setHttpTimeout(inTimeout);
rest.waitForResponse(inTimeout);
rest.setRequestHeader('Content-Type', 'application/json');
rest.setRequestHeader('Accept', 'application/json');
rest.setHttpMethod('post');
rest.setRequestBody(inPayload);
for ( var i = 0; i < 3; i++ ) {
try {
var response = rest.execute();
sResponseBody = response.getBody();
nResponseCode = response.getStatusCode();
sResponseEndpoint = response.getEndpoint();
sResponseHeaders = response.getRequestHeaders();
break;
} catch( err ) {
sResponseMessage = err.getMessage();
gs.sleep(5000);
}
}
return {"ResponseCode":nResponseCode,"ResponseBody":sResponseBody,"ResponseMessage":sResponseBody,"ResponseEndpoint":sResponseEndpoint, "ResponseHeaders":sResponseHeaders};
}
This will tell you how to create an inbound webhook:
https://api.slack.com/incoming-webhooks
Here's an example payload we use. The ${tags} are simple macros we use to get value from the source ticket. You can simply dotwalk in the BR.
{
"username":"${SlackUsername}",
"attachments":[{
"title":"Short description",
"title_link":"${URL}",
"text":"${ShortDescription}",
"fallback":"${ShortDescription}",
"color":"${Color}",
"footer":"${SlackUsername}",
"fields":[
{"title":"State","value":"${State}","short":true},
{"title":"Priority","value":"${Priority}","short":true},
{"title":"Assignment group","value":"${AssignmentGroup}","short":true},
{"title":"Assigned to","value":"${AssignedTo}","short":true},
{"title":"Technical Service","value":"${TechnicalService}","short":true},
{"title":"Configuration item","value":"${ConfigurationItem}","short":true},
{"title":"Details","value":"${Description}","short":false}
],
"ts":"${TimeStampEpoch}"
}
]
}
For info:
We use a custom table with conditions set to trigger a post to Slack. Users can simply create their own filters as required. The endpoint used is an inbound webhook provided by the user.
An async business rule runs on task to review conditions and action as required.
The current work on this is to use a Slack app so we can post to any channel by channel id. This means we don't risk the issue of someone creating an inbound webhook then leaving the company.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there any recommendation for SMS plugin which can be easily integrated with Grails?
I'm building a management system which sends customers Y/N confirmation via text message.
The cost and deliverance quality of SMS services depends on which countries you will be sending SMS to, but (prior to changing to a Swedish vendor) we have used the international vendor Clickatell with ok results.
You don't need a Grails plugin for that, just use HTTPBuilder (e.g. by including the Grails REST plugin) with Grails to call the Clickatell API according to their documentation.
Here is some old sample code (may not be working if the API has changed):
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.EncoderRegistry
import static groovyx.net.http.Method.POST
import static groovyx.net.http.ContentType.URLENC
import static groovyx.net.http.ContentType.TEXT
def http = new HTTPBuilder(host)
http.contentType = TEXT
EncoderRegistry encoders = new EncoderRegistry();
encoders.setCharset('ISO-8859-1')
http.setEncoderRegistry(encoders)
http.request(POST) {
uri.path = 'http/sendmsg'
requestContentType = URLENC
body = [api_id: '1234567', user: 'john', password: 'doe', from: 'Company', to: NUMBER, text: 'Hello world', concat: '3', callback: '2', deliv_ack: '1']
response.success = { resp, reader ->
def msg = reader.text
if (msg.substring(0, 2) == 'ID') {
} else if (msg.substring(0, 3) == 'ERR') {
} else {
}
}
response.failure = { resp ->
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have gem that returns next hash object
{:response=>"There was an error authenticating the sender account.", :status_code=>401}
and in my rake task i'm trying to access it's properties:
response = my_gem.execute
puts response
puts response.has_key?(:respose)
puts response[:respose]
But i can't understand why it prints
{:response=>"There was an error authenticating the sender account.", :status_code=>401}
false
Why can't i access :response property with response[:respose] ?
P.S. response[response.keys.first] works but it's very weird solution
There is a typo in the below :
puts response.has_key?(:respose)
has_key?(:respose) should be has_key?(:response).
response = {:response=>"There was an error authenticating the sender account.", :status_code=>401}
response.has_key?(:response)
# => true
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have my /etc/postfix/virtual file:
sub.domain.com DOMAIN
#sub.domain.com user2
domain.com DOMAIN
#domain.com user1
The mail for #sub.domain.com still goes to user1 and that's not what I want.
Here's my /etc/postfix/my.cnf just in cases:
mydomain = domain.com
myhostname = mail.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
myorigin = $mydomain
mydestination = $myhostname, $mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 1073741824
recipient_delimiter = +
inet_interfaces = all
parent_domain_matches_subdomains =
Note, that I set parent_domain_matches_subdomains to empty. But it still doesn't help. Any ideas?
The right hand side of your virtual_alias_maps table is an unqualified username.
Postfix appends $myorigin to unqualified usernames, making it effectively
#sub.example.com user2#example.com
#example.com user1#example.com
Now user2#example.com is caught by the catchall for #example.com.
Hence, mail for user2#example.com goes to user1.
You could change your Postfix config to this:
mydomain = example.com
myhostname = mail.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
myorigin = $mydomain
mydestination = $myhostname, $mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 1073741824
recipient_delimiter = +
inet_interfaces = all
parent_domain_matches_subdomains =
virtual_alias_domains = sub.example.com
luser_relay = user2#example.com
/etc/postfix/virtual
#sub.example.com user1#example.com
Create two system accounts user1 and user2.