Skip to content

Commit 440ec4d

Browse files
authored
[Backport 7.x] OpenID Connect realm guide (#42836)
This commit adds a configuration guide for the newly introduced OpenID Connect realm. The guide is similar to the style of the SAML Guide and shares certain parts where applicable (role mapping) It also contains a short section on how the realm can be used for authenticating users without Kibana. Co-Authored-By: Lisa Cawley <[email protected]> Backport of #41423 and #42555
1 parent 928f499 commit 440ec4d

File tree

7 files changed

+714
-16
lines changed

7 files changed

+714
-16
lines changed

x-pack/docs/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,26 @@ project.copyRestSpec.from(xpackResources) {
3131
}
3232

3333
testClusters.integTest {
34+
extraConfigFile 'op-jwks.json', xpackProject('test:idp-fixture').file("oidc/op-jwks.json")
3435
setting 'xpack.security.enabled', 'true'
3536
setting 'xpack.security.authc.api_key.enabled', 'true'
3637
setting 'xpack.security.authc.token.enabled', 'true'
3738
// Disable monitoring exporters for the docs tests
3839
setting 'xpack.monitoring.exporters._local.type', 'local'
3940
setting 'xpack.monitoring.exporters._local.enabled', 'false'
4041
setting 'xpack.license.self_generated.type', 'trial'
42+
setting 'xpack.security.authc.realms.file.file.order', '0'
43+
setting 'xpack.security.authc.realms.native.native.order', '1'
44+
setting 'xpack.security.authc.realms.oidc.oidc1.order', '2'
45+
setting 'xpack.security.authc.realms.oidc.oidc1.op.issuer', 'http://127.0.0.1:8080'
46+
setting 'xpack.security.authc.realms.oidc.oidc1.op.authorization_endpoint', "http://127.0.0.1:8080/c2id-login"
47+
setting 'xpack.security.authc.realms.oidc.oidc1.op.token_endpoint', "http://127.0.0.1:8080/c2id/token"
48+
setting 'xpack.security.authc.realms.oidc.oidc1.op.jwkset_path', 'op-jwks.json'
49+
setting 'xpack.security.authc.realms.oidc.oidc1.rp.redirect_uri', 'https://my.fantastic.rp/cb'
50+
setting 'xpack.security.authc.realms.oidc.oidc1.rp.client_id', 'elasticsearch-rp'
51+
keystore 'xpack.security.authc.realms.oidc.oidc1.rp.client_secret', 'b07efb7a1cf6ec9462afe7b6d3ab55c6c7880262aa61ac28dded292aca47c9a2'
52+
setting 'xpack.security.authc.realms.oidc.oidc1.rp.response_type', 'id_token'
53+
setting 'xpack.security.authc.realms.oidc.oidc1.claims.principal', 'sub'
4154
user username: 'test_admin'
4255
}
4356

x-pack/docs/en/rest-api/security.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ native realm:
7676
* <<security-api-enable-user,Enable users>>
7777
* <<security-api-get-user,Get users>>
7878

79+
[float]
80+
[[security-openid-apis]]
7981
=== OpenID Connect
8082

8183
You can use the following APIs to authenticate users against an OpenID Connect
@@ -110,7 +112,7 @@ include::security/get-users.asciidoc[]
110112
include::security/has-privileges.asciidoc[]
111113
include::security/invalidate-api-keys.asciidoc[]
112114
include::security/invalidate-tokens.asciidoc[]
113-
include::security/ssl.asciidoc[]
114115
include::security/oidc-prepare-authentication-api.asciidoc[]
115116
include::security/oidc-authenticate-api.asciidoc[]
116117
include::security/oidc-logout-api.asciidoc[]
118+
include::security/ssl.asciidoc[]

x-pack/docs/en/rest-api/security/authenticate.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ The following example output provides information about the "rdeniro" user:
4646
"metadata": { },
4747
"enabled": true,
4848
"authentication_realm": {
49-
"name" : "default_file",
49+
"name" : "file",
5050
"type" : "file"
5151
},
5252
"lookup_realm": {
53-
"name" : "default_file",
53+
"name" : "file",
5454
"type" : "file"
5555
}
5656
}

x-pack/docs/en/rest-api/security/oidc-authenticate-api.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ POST /_security/oidc/authenticate
5151
}
5252
--------------------------------------------------
5353
// CONSOLE
54-
// TEST[skip:These are properly tested in the OpenIDConnectIT suite]
54+
// TEST[catch:unauthorized]
5555

5656
The following example output contains the access token that was generated in response, the amount of time (in
5757
seconds) that the token expires in, the type, and the refresh token:

x-pack/docs/en/rest-api/security/oidc-logout-api.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ POST /_security/oidc/logout
3939
}
4040
--------------------------------------------------
4141
// CONSOLE
42-
// TEST[skip:These are properly tested in the OpenIDConnectIT suite]
42+
// TEST[catch:unauthorized]
4343

4444
The following example output of the response contains the URI pointing to the End Session Endpoint of the
4545
OpenID Connect Provider with all the parameters of the Logout Request, as HTTP GET parameters

x-pack/docs/en/rest-api/security/oidc-prepare-authentication-api.asciidoc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,19 @@ POST /_security/oidc/prepare
5757
}
5858
--------------------------------------------------
5959
// CONSOLE
60-
// TEST[skip:These are properly tested in the OpenIDConnectIT suite]
61-
6260
The following example output of the response contains the URI pointing to the Authorization Endpoint of the
6361
OpenID Connect Provider with all the parameters of the Authentication Request, as HTTP GET parameters
6462

6563
[source,js]
6664
--------------------------------------------------
6765
{
68-
"redirect" : "https://op-provider.org/login?scope=openid&response_type=code&redirect_uri=http%3A%2F%2Foidc-kibana.elastic.co%3A5603%2Fkmi%2Fapi%2Fsecurity%2Fv1%2Foidc&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I&nonce=WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM&client_id=0o43gasov3TxMWJOt839",
66+
"redirect" : "http://127.0.0.1:8080/c2id-login?scope=openid&response_type=id_token&redirect_uri=https%3A%2F%2Fmy.fantastic.rp%2Fcb&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I&nonce=WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM&client_id=elasticsearch-rp",
6967
"state" : "4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
7068
"nonce" : "WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM"
7169
}
7270
--------------------------------------------------
73-
// NOTCONSOLE
71+
// TESTRESPONSE[s/4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I/\$\{body.state\}/]
72+
// TESTRESPONSE[s/WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM/\$\{body.nonce\}/]
7473

7574
The following example generates an authentication request for the OpenID Connect Realm `oidc1`, where the
7675
values for the state and the nonce have been generated by the client
@@ -85,20 +84,19 @@ POST /_security/oidc/prepare
8584
}
8685
--------------------------------------------------
8786
// CONSOLE
88-
// TEST[skip:These are properly tested in the OpenIDConnectIT suite]
8987

9088
The following example output of the response contains the URI pointing to the Authorization Endpoint of the
9189
OpenID Connect Provider with all the parameters of the Authentication Request, as HTTP GET parameters
9290

9391
[source,js]
9492
--------------------------------------------------
9593
{
96-
"redirect" : "https://op-provider.org/login?scope=openid&response_type=code&redirect_uri=http%3A%2F%2Foidc-kibana.elastic.co%3A5603%2Fkmi%2Fapi%2Fsecurity%2Fv1%2Foidc&state=lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO&nonce=zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5&client_id=0o43gasov3TxMWJOt839",
94+
"redirect" : "http://127.0.0.1:8080/c2id-login?scope=openid&response_type=id_token&redirect_uri=https%3A%2F%2Fmy.fantastic.rp%2Fcb&state=lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO&nonce=zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5&client_id=elasticsearch-rp",
9795
"state" : "lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO",
9896
"nonce" : "zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5"
9997
}
10098
--------------------------------------------------
101-
// NOTCONSOLE
99+
// TESTRESPONSE
102100

103101
The following example generates an authentication request for a 3rd party initiated single sign on, specifying the
104102
issuer that should be used for matching the appropriate OpenID Connect Authentication realm
@@ -107,22 +105,22 @@ issuer that should be used for matching the appropriate OpenID Connect Authentic
107105
--------------------------------------------------
108106
POST /_security/oidc/prepare
109107
{
110-
"issuer" : "https://op-issuer.org:8800",
108+
"iss" : "http://127.0.0.1:8080",
111109
"login_hint": "this_is_an_opaque_string"
112110
}
113111
--------------------------------------------------
114112
// CONSOLE
115-
// TEST[skip:These are properly tested in the OpenIDConnectIT suite]
116113

117114
The following example output of the response contains the URI pointing to the Authorization Endpoint of the
118115
OpenID Connect Provider with all the parameters of the Authentication Request, as HTTP GET parameters
119116

120117
[source,js]
121118
--------------------------------------------------
122119
{
123-
"redirect" : "https://op-provider.org/login?scope=openid&response_type=code&redirect_uri=http%3A%2F%2Foidc-kibana.elastic.co%3A5603%2Fkmi%2Fapi%2Fsecurity%2Fv1%2Foidc&state=lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO&nonce=zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5&client_id=0o43gasov3TxMWJOt839&login_hint=this_is_an_opaque_string",
120+
"redirect" : "http://127.0.0.1:8080/c2id-login?login_hint=this_is_an_opaque_string&scope=openid&response_type=id_token&redirect_uri=https%3A%2F%2Fmy.fantastic.rp%2Fcb&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I&nonce=WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM&client_id=elasticsearch-rp",
124121
"state" : "4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
125122
"nonce" : "WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM"
126123
}
127124
--------------------------------------------------
128-
// NOTCONSOLE
125+
// TESTRESPONSE[s/4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I/\$\{body.state\}/]
126+
// TESTRESPONSE[s/WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM/\$\{body.nonce\}/]

0 commit comments

Comments
 (0)