ãã®è¨äºã¯ Akerun - Qiita Advent Calendar 2024 - Qiita ã® 8 æ¥ç®ã®è¨äºã§ãã
ã©ãã daikw - Qiita ã§ãã
æè¿ãå¦è¡èªè¨¼ãã§ãã¬ã¼ã·ã§ã³ï¼å¦èª, GakuNinï¼ã調ã¹ãæ©ä¼ãããã Shibboleth ãåæã¨ããè¨è¿°ãå¤ãã£ãã®ã§ã試ãã« Shibboleth ãµã¼ãã建ã¦ã¦ãã¹ããã§ãã¬ã¼ã·ã§ã³ç³è«ã¾ã§ä¸éããã£ã¦ã¿ã¾ããã
以ä¸ã®è¨äºã»ä»æ§ãåèã«ãã¾ããã
- å¦èªæè¡éç¨åºæº | å¦è¡èªè¨¼ãã§ãã¬ã¼ã·ã§ã³ å¦èª GakuNin
- å¦èªç³è«ã·ã¹ãã å©ç¨ããã¥ã¢ã«(ãã¹ãfed)_3
- SPã»ããã£ã³ã° - GakuNinShibInstall - meatwiki
ã·ãã¬ã¹
ã·ãã¬ã¹ - Wikipedia ã«ããã¨ã
ãªããã·ãã¬ã¹ãã¨ã¯ãããã©ã¤èªèæ¸ã®é¸è©±ã«ç±æ¥ããèªå½ã®ç¹æ®ãªçºé³ãè¦ãããã¬ã¼ãºãèªã¿ä¸ããããäºã§ãç¸æãæµå½äººã®ã¹ãã¤ãã©ãããå¤å¥ããã®ã«ç¨ããããä¸ä¸ã¨ã¼ãããã®é²è«ææ³ã®ä¸ç¨®ã§ããã
SAMLãã§ãã¬ã¼ã·ã§ã³ç°å¢ä¸ã§ã Shibboleth ã¯çµç¹éã®ãä¿¡é ¼ã®åè¨èãã¨ãè¨ããè¦ç´ã»ã¡ã¿ãã¼ã¿ãåªä½ã«ãäºãã®ã¦ã¼ã¶ã¼ãæ£çµ±ãªã¢ã¯ã»ã¹æ¨©ãæã¤ãã¨ãä¿è¨¼ããå½¹å²ãæããã®ã§ãè¯ãå½åã§ããã
è¸ã¿çµµã¨æ§é ãä¼¼ã¦ãããªã¨æãã¾ãããããèå¥å¯¾è±¡ããè¨èªçç¿æ £ããªã®ããå®æçå é¢ããªã®ãã¨ããç¹ãã§æ確ã«éãã¾ãããFumie ã¯ãµã¼ãã¹åã«ã¯ã§ããªããã
æ§æ
GCE ã¤ã³ã¹ã¿ã³ã¹ä¸ã¤ã§å®çµããããã«ãã¾ããã
GIP ãå²ãå½ã¦ããã¡ã¤ã³åãè¨å®ãããµã¼ãå 㧠shibboleth ãµã¼ãã¹ãåããã¾ãã OS ã«ã¯ Rocky Linux 8 ãå©ç¨ãã¾ããã
curl -O 'https://shibboleth.net/cgi-bin/sp_repo.cgi?platform=CentOS_7' sudo cp sp_repo.cgi\?platform=* /etc/yum.repos.d/shibboleth.repo sudo dnf install shibboleth httpd epel-release certbot python3-certbot-apache # ãµã¼ãã¹èµ·å sudo systemctl start shibd sudo systemctl enable shibd sudo systemctl start httpd sudo systemctl enable httpd # ãããªã«ç·¨éã㦠certbot ã§è¨¼ææ¸çºè¡ sudo vim /etc/httpd/conf.d/ssl.conf sudo certbot --apache --email [email protected] # shibboleth ã®è¨å®ãå¤æ´ããªã¹ã¿ã¼ã sudo vim /etc/shibboleth/shibboleth2.xml sudo systemctl restart shibd
ãã©ãã«ã·ã¥ã¼ã
2ã¤ã»ã©è¿·ãæåã«è¦èããã¾ããã ãªãã shibboleth ãµã¼ãã¹ãèµ·åãã¦ããã°ããã¼ã«ã«ããã¢ã¯ã»ã¹ã§ããããã¤ãã®ç®¡çç¨ã¨ã³ããã¤ã³ããå©ç¨ã§ãã¾ããããã§ãã©ãã«ã·ã¥ã¼ããã§ãã¾ãã
# ãµã¼ãã®ç¶æ ãç¢ºèª curl -k -s https://localhost/Shibboleth.sso/Status # ã¡ã¿ãã¼ã¿ãç¢ºèª curl -k -s https://localhost/Shibboleth.sso/Metadata # æå¹ãªã»ãã·ã§ã³ãç¢ºèª curl -k -s https://localhost/Shibboleth.sso/Session
SELinux ãå¼¾ãã¦ãã
ã¨ãããã shibboleth ãµã¼ãã¹ã®èµ·åã¾ã§ã¯ä¸æ¯ã§è¡ãã¾ããããä½ãã§å¼¾ããã¦ããããã§ãã
[daikiwatanabe@shibboleth-sp ~]$ curl -k -s https://localhost/Shibboleth.sso/Status <StatusHandler time='2024-11-11T04:36:16Z'><Version Xerces-C='3.3.0' XML-Tooling-C='3.3.0' Shibboleth='3.5.0'/><NonWindows sysname='Linux' nodename='shibboleth-sp' release='4.18.0-553.16.1.el8_10.cloud.0.1.x86_64' version='#1 SMP Thu Sep 12 13:56:18 UTC 2024' machine='x86_64'/><Status><Exception type='shibsp::ListenerException'>Cannot connect to shibd process, a site administrator should be notified that this web server has malfunctioned.</Exception></Status></StatusHandler>[daikiwatanabe@shibboleth-sp ~]$
ãã調ã¹ã¦ã¿ãã¨ã SELinux ã shibd.sock
ã¸ã®ã¢ã¯ã»ã¹ãå¼¾ãã¦ãã¾ããã
[daikiwatanabe@shibboleth-sp ~]$ getenforce Enforcing [daikiwatanabe@shibboleth-sp ~]$ sudo ausearch -m avc | head ---- time->Mon Nov 11 01:25:30 2024 type=PROCTITLE msg=audit(1731288330.723:6915): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44 type=SYSCALL msg=audit(1731288330.723:6915): arch=c000003e syscall=42 success=no exit=-13 a0=14 a1=7f1f31ff5ff0 a2=6e a3=39 items=0 ppid=86642 pid=87819 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1731288330.723:6915): avc: denied { write } for pid=87819 comm="httpd" name="shibd.sock" dev="tmpfs" ino=103453 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0 ---- time->Mon Nov 11 01:25:32 2024 type=PROCTITLE msg=audit(1731288332.724:6916): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44 type=SYSCALL msg=audit(1731288332.724:6916): arch=c000003e syscall=42 success=no exit=-13 a0=14 a1=7f1f31ff5ff0 a2=6e a3=39 items=0 ppid=86642 pid=87819 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1731288332.724:6916): avc: denied { write } for pid=87819 comm="httpd" name="shibd.sock" dev="tmpfs" ino=103453 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0
audit2allow
ã使ã£ã¦ããªã·ã¼ãèªåä½æãã semodule
ã§é©ç¨ãã¾ãã
[daikiwatanabe@shibboleth-sp ~]$ sudo dnf -y install policycoreutils-python-utils ... [daikiwatanabe@shibboleth-sp ~]$ sudo ausearch -c 'httpd' --raw | audit2allow -M httpd_shibd_policy ******************** IMPORTANT *********************** To make this policy package active, execute: semodule -i httpd_shibd_policy.pp [daikiwatanabe@shibboleth-sp ~]$ sudo semodule -i httpd_shibd_policy.pp
åä½ããããã«ãªãã¾ããã
[daikiwatanabe@shibboleth-sp ~]$ curl -k -s https://localhost/Shibboleth.sso/Status <StatusHandler time='2024-11-11T04:44:50Z'><Version Xerces-C='3.3.0' XML-Tooling-C='3.3.0' XML-Security-C='3.0.0' OpenSAML-C='3.3.0' Shibboleth='3.5.0'/><NonWindows sysname='Linux' nodename='shibboleth-sp' release='4.18.0-553.16.1.el8_10.cloud.0.1.x86_64' ... </ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><md:KeyDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" use="encryption"><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:KeyName>shibboleth-sp</ds:KeyName><ds:X509Data><ds:X509SubjectName>CN=shibboleth-sp</ds:X509SubjectName><ds:X509Certificate> ... </ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><Status><OK/></Status></StatusHandler>
証ææ¸ã®æºå
証ææ¸ã®è¨å®ã«å°ãæãããã¾ããããã§ãã¬ã¼ã·ã§ã³ç³è«ã«ã¯è¨¼ææ¸ãæ·»ä»ããå¿ è¦ãããã¾ãã
å ã»ã© certbot 㧠HTTPS ç¨ã®ãµã¼ã証ææ¸ãçºè¡ãã¾ããã ã¾ããshibboleth ã¯ã¤ã³ã¹ãã¼ã«æã«èªå·±ç½²å証ææ¸ã2ã¤çæãã¾ãã
[daikiwatanabe@shibboleth-sp shibboleth]$ find /etc/shibboleth -regex '.*.pem' /etc/shibboleth/sp-signing-key.pem /etc/shibboleth/sp-signing-cert.pem /etc/shibboleth/sp-encrypt-key.pem /etc/shibboleth/sp-encrypt-cert.pem
ãããã§ãã¬ã¼ã·ã§ã³ã®ç³è«æ¸ã«ã¯è¨¼ææ¸ã®ç»é²å ´æãä¸ã¤ã ãåå¨ãã¦ãã¾ããã©ã¡ããç»é²ããã¹ããããã¥ã¢ã«ä¸ã¯æ確ã«ã¯åããã¾ããã§ããã以ä¸ã®äºå®ããã確å®ã§ãããã¨ãããã sigining
ã§ããã ããã¨å¤æãã¾ãããã©ã¡ãã§ãããã®ããããã¾ããã
- çæããã証ææ¸ã®ç¨é (
use
è¦ç´ ) ã¯encryption
/sigining
ã®2ã¤ããã- ãã®è¦ç´ ã®å¤ã®åè£ã¯
FileCredentialResolver
ã«è¨è¼ããã
- ãã®è¦ç´ ã®å¤ã®åè£ã¯
- ããã¥ã¢ã« ä¸ã¯ããSAML ç½²ååã³æå·åã«ä½¿ç¨ãã証ææ¸ãã¨è¨è¿°ããã
ã¾ãã Letâs Encrypt (certbot) ã®ãã«ãã§ã¼ã³è¨¼ææ¸ã試ãã«å ¥åããã¨ããããèªå·±ç½²å証ææ¸ã¨åæ§ã¨å¤å®ããã¾ããã
èªå·±ç½²å証ææ¸ãå«ãã¡ã¿ãã¼ã¿ãç³è«ããå ´åãããããµã¼ãä¸ã§å ¬éããå¿ è¦ãããã¾ãã IdP/SPã§ããããªãã¯ã§ãªã証ææ¸ãï¼èªå·±ç½²å証ææ¸ï¼ãå©ç¨ããå ´å - GakuNinShibInstall - meatwiki
/var/www/html
ãã£ã¬ã¯ããªã使ã£ã¦ã Apache ã®ããã©ã«ãã®è¨å®ãå©ç¨ãã¦è¨¼ææ¸ãé²åºããã¾ãã
sudo mkdir -p /var/www/html/cert sudo cp /etc/shibboleth/sp-signing-cert.pem /var/www/html/cert
ãããã㨠https://shibsp.your.domain/cert/sp-signing-cert.pem
ã§ç¢ºèªã§ããã®ã§ããããç³è«æ¸ã«è¨è¼ãã¾ãã
ãªãããµã¼ãã¹ã§å©ç¨ãã証ææ¸ã¯ TLS 証ææ¸ã¨åé¢ãã¦ããã®ãè¯ãã¨èãã¾ãããªããªããTLS証ææ¸ã®ãã¼ãã¼ãã¨ãã§ãã¬ã¼ã·ã§ã³ã¡ã¿ãã¼ã¿ã®ãã¼ãã¼ããåæã«è¡ãã®ã¯é£ããããã§ãã
ãã®ä»ãæ°ãã¤ãããã¨ãããã¤ãããã¾ããã
- çæããã¡ã¿ãã¼ã¿ã®ä¸èº«ãä¿®æ£ãã¦ãã§ãã¬ã¼ã·ã§ã³ã«æåºããã®ãã¨æããããç³è«æ¸ãã©ã¼ããããã¡ã¿ãã¼ã¿ã«å¯¾å¿ãã¦ãã¾ããã shibboleth ãå©ç¨ãã¦ããå ´åã¯äºåº¦æéã«ãªãã¾ãã
- shibboleth 以å¤ã® SAML å®è£ åãã«ãããã³ãã¬ã¼ãå¤ã¡ã¿ãã¼ã¿ãã¨ããé ç®ãããã¾ããã shibboleth ã«ãã ãã£ã¦ããããã§ã¯ãªãããã§ãã
ãã¹ããã§ãã¬ã¼ã·ã§ã³ç³è«
æºåãããµã¼ãã®æ å ±ã使ã£ã¦ç³è«ãããã
1æ¥ã§æ¿èªããã¾ãããè¿ éï¼äºåå±ã®æ¹ãããã¨ããããã¾ããã
ã¾ã¨ã
- ã¿ã¤ãã«éã 30 åã§ç¨æããã®ã¯çµæ§å¤§å¤ã§ããã1æéãããã°ç¨æã§ããã¨æãã¾ã
- å¦çæ代ã«è§¦ã£ã¦ãã GakuNin ã®ãã°ã¤ã³ç»é¢ãéç¨ãã¦ããä»çµã¿ããããã¦ããã£ãã§ã
æ ªå¼ä¼ç¤¾ãã©ãã·ã³ã¹ã§ã¯ãä¸ç·ã«ãããã¯ããæé·ãããæ§ã ãªã¬ã¤ã¤ã®ã¨ã³ã¸ãã¢ãåéãã¦ãã¾ãã hrmos.co
Akerun Pro ã®è³¼å ¥ã¯ãã¡ããã akerun.com