Hello, I have NGINX proxy server which forwards requests to kibana. I wanted to have SSO authentication using SAML for Kibana. My setup is as below:
(1)NGIX config:
server {
listen 443;
server_name gpcs-sre-nonprod-elk.panclouddev.com, 10.181.131.242;
ssl on;
ssl_certificate /etc/nginx/ssl/FQDN.pem;
ssl_certificate_key /etc/nginx/ssl/FQDN.key;
location /kibana {
proxy_pass https://172.20.241.201;
proxy_set_header X-Forwarded-Host FQDN;
#proxy_set_header sec-fetch-mode cors;
proxy_set_header kbn-xsrf 7.1.1;
}
(2) ES config.yml
elasticsearch.yml: |
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.truststore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.http.ssl.keystore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.authc.token.enabled: true
xpack.security.authc.realms.saml.kibana_saml:
order: 2
idp.metadata.path: saml/idp-metadata.xml
idp.entity_id: "http://www.okta.com/<randomstring_id>"
sp.entity_id: "https://FQDN/kibana"
sp.acs: "https://FQDN/kibana/api/security/v1/saml"
sp.logout: "https://FQDN/kibana/logout"
attributes.principal: "nameid"
attributes.groups: "roles"
attributes.mail: "mail"
xpack.security.authProviders: [saml]
xpack.security.auth.saml.realm: kibana_saml
(3) Kibana yml
data:
kibana.yml: |
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
server.basePath: "/kibana"
server.rewriteBasePath: true
elasticsearch.hosts: "https://elasticsearch-master:9200"
server.ssl:
enabled: true
key: /usr/share/kibana/config/certs/kibana/kibana.key
certificate: /usr/share/kibana/config/certs/kibana/kibana.crt
xpack.security.encryptionKey: something_at_least_32_characters
xpack.security.public:
protocol: https
hostname: FQDN
port: 443
server.xsrf.whitelist: [/api/security/v1/saml]
elasticsearch.ssl:
certificateAuthorities: /usr/share/kibana/config/certs/elastic-certificate.pem
verificationMode: certificate
(4) idp-metadata.xml
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="http://www.okta.com/<randomstring_id">
<md:IDPSSODescriptor WantAuthnRequestsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
ds:X509Data
ds:X509Certificate
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
md:NameIDFormat
urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
</md:NameIDFormat>
md:NameIDFormat
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
</md:NameIDFormat>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https:////sso/saml"/>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="//sso/saml"/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>
(5) logs in kibana pod
{"type":"response","@timestamp":"2019-10-29T01:35:07Z","tags":,"pid":1,"method":"post","statusCode":401,"req":{"url":"/api/security/v1/saml","method":"post","headers":{"x-forwarded-host”:”FQDN”,”kbn-xsrf":"7.1.1","host":"172.20.241.201","connection":"close","content-length":"41041","cache-control":"max-age=0","origin":"https://.okta.com","upgrade-insecure-requests":"1","dnt":"1","content-type":"application/x-www-form-urlencoded","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36","sec-fetch-mode":"navigate","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3","sec-fetch-site":"cross-site","referer":"https://.okta.com/app/prod_elasticsearchdev_1/<randomstring_id>/sso/saml","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9"},"remoteAddress":"172.20.240.46","userAgent":"172.20.240.46","referer":"https://.okta.com/app/prod_elasticsearchdev_1/<randomstring_id>/sso/saml"},"res":{"statusCode":401,"responseTime":25,"contentLength":9},"message":"POST /api/security/v1/saml 401 25ms - 9.0B"}
(6) message on the browser is :
{"statusCode":401,"error":"Unauthorized","message":"Unauthorized"}
I am trying directly the URL appearing in idp-metadata.xml file as it appears in sso binding line in the end. It does go to okta and it does send backs the token but somehow kibana is declining the request. Any help would be greatly appreciated.