OpenID Connect
Michal Prochazka, Dominik Bucik
AAI workshop 11 September 2018
European Life Sciences Infrastructure for Biological Information
www.elixir-europe.org
European Life Sciences Infrastructure for Biological Information
www.elixir-europe.org
Outline
Registration into the ELIXIR Test Environment
www.elixir-europe.org
Obtaining the ELIXIR ID
https://signup.aai.lifescience-ri.eu/registrar/?vo=lifescience_test
Service Registration
Application with OIDC support
www.elixir-europe.org
Required configuration options
Register service
Register service in MITREid (2)
https://[your machine]/oauth2callback
Step 1 - Main tab
Callback: https://[your machine]/oauth2callback
Step 2 - Access tab
Web service on a server
www.elixir-europe.org
Web service on server
Web service on server
#> apt install apache2 git vim wget libjansson4 libhiredis0.13 libcurl3
#> wget https://github.com/zmartzone/mod_auth_openidc/releases/download/v2.3.0/libcjose0_0.5.1-1.stretch.1_amd64.deb
#> wget https://github.com/zmartzone/mod_auth_openidc/releases/download/v2.3.3/libapache2-mod-auth-openidc_2.3.3-1.stretch.1_amd64.deb
#> dpkg -i libcjose0_0.5.1-1.stretch.1_amd64.deb libapache2-mod-auth-openidc_2.3.3-1.stretch.1_amd64.deb
Web service on server
#> a2enmod auth_openidc cgi ssl
#> apache2ctl -t
Syntax OK
#> systemctl restart apache2
Configure Apache
OIDCProviderMetadataURL https://login.elixir-czech.org/oidc/.well-known/openid-configuration�OIDCProviderMetadataRefreshInterval 3600�OIDCClientID b2bc0708-ec82-418b-a727-42526a99f29c # (fill yours)�OIDCClientSecret Eowd2VeXuJ88eFpaEowd2VeXuJ88eFpaEowd2VeXuJ88eFpa # (fill yours)�OIDCScope "openid profile"�OIDCRedirectURI /oauth2callback�OIDCCryptoPassphrase randompassword�
<Location /oauth2callback>� #non-existent location for returning from OIDC server� AuthType openid-connect� Require valid-user� </Location>� <Location /cgi-bin/>� #actually protected URLs� AuthType openid-connect� Require valid-user� </Location>
Configure Apache
#> nano /etc/apache2/sites-available/default-ssl.conf
#> a2ensite default-ssl.conf
#> service apache2 restart
Sample CGI script
#!/bin/bash
echo -e "Content-type: text/plain\n"
echo -e "Printing environment variables for OIDC\n\n"
set | grep OIDC_
Login as a user
https://[machine_name]/cgi-bin/
Data in CGI variables
Printing environment variables for OIDC���OIDC_CLAIM_aud=22602425-bf20-4e36-b096-dd38417918c0�OIDC_CLAIM_auth_time=1524500299�OIDC_CLAIM_exp=1524501330�OIDC_CLAIM_iat=1524500730�OIDC_CLAIM_iss=https://login.elixir-czech.org/oidc/�OIDC_CLAIM_jti=8dd2b3e5-b173-47e6-8b15-3e01839f4ae8�OIDC_CLAIM_kid=rsa1�OIDC_CLAIM_nonce=l3lwZIKhzQY7Xyml4socbAWLU11bscRW2OC5C721PVk�OIDC_CLAIM_sub=a78efcaa0459f492590tefa3cece12875a0a3504@elixir-europe.org
JavaScript client
www.elixir-europe.org
JavaScript client
https://[machine_name]/callback.html
Callback URL
#> nano /var/www/html/callback.html
Minimalistic client in JavaScript
#> nano /var/www/html/index.html
Application logic
#> nano /var/www/html/app.js
Download oidc-client-js library
#> git clone https://github.com/IdentityModel/oidc-client-js.git /var/www/html/oidc-client-js-1.4.1
#> cd /var/www/html/oidc-client-js-1.4.1
#> git checkout 1.4.1
Test it
Visit https://machine_name]/
Virtual machines and clients created during this meeting will be deleted on 18th of September 2018.
Own implementation
www.elixir-europe.org
Own implementation
https://login.elixir-czech.org/oidc/.well-known/openid-configuration
Own implementation - step 1
https://login.elixir-czech.org/oidc/authorize?
response_type=code
&scope=openid+email+profile+address+phone
&client_id=<client_id>
&redirect_uri=<where to redirect back>
&state=<random value against XSRF attack>
Own implementation - step 2
#>curl -d "grant_type=authorization_code&code=<value of code>&redirect_uri=<value from the first step>&client_id=<client_id>&client_secret=<client_secret>" https://login.elixir-czech.org/oidc/token
Own implementation - step 3
#>curl -H "Authorization: Bearer <access_token>" https://login.elixir-czech.org/oidc/userinfo
User claims
{
"sub":"fafefcaa0561ad9259adfa9fa3cece1dfadf75a03428@elixir-europe.org",
"name":"Michal Procházka",
"Preferred_username":"michalp",
"given_name":"Michal",
"family_name":"Procházka",
"email":"michalp@ics.muni.cz",
"Phone_number":"+420739xxxxxx",
"address":{}
}
How to move to production
www.elixir-europe.org
Procedure
Formalities
European Life Sciences Infrastructure for Biological Information
www.elixir-europe.org
European Life Sciences Infrastructure for Biological Information
www.elixir-europe.org