1
0

Voicy で SRE として昨年の6月に入社したので、やっと1年を過ぎました
今日は、saml2aws について少し書いていきたいと思います

AWSにGoogle Authでログイン

  • AWSへのログインをする際、SAML2を利用して GoogleアカウントによるSSOが可能です
  • Webの場合はよいですが、CLIを使用する場合はちょっと面倒な感じです
  • CLIの場合、aws-google-authやsaml2awsを使用すると楽です

aws-google-authの場合

  • 最近Googleログインの仕様が変更され、下記のようにログインができなくなっています
% aws-google-auth                                            
Google Password: ぱすわーど入れる
Please visit the following URL to view your CAPTCHA: https://accounts.google.com/Captcha?v=2&ctoken=******
Captcha (case insensitive): きゃぷちゃに表示された文字列入れる
Something went wrong - Could not find SAML response, check your credentials or use --save-failure-html to debug.
  • ブラウザのSAML応答を取ってくれば一応回避できます
  • 最近更新されてないです(修正PRは出てるが、それでもエラーになる場合がある)
  • うん、違うの探した方がいいなー

saml2awsの場合

  • デフォルトモードだと同じく失敗します(saml2awsよお前もか!)
% saml2aws login       
Using IdP Account default to access GoogleApps https://accounts.google.com/o/saml2/initsso?idpid=******&spid=1234567890&forceauthn=false
To use saved password just hit enter.
? Username GoogleWorkspaceめあどいれる
? Password ぱすわーどいれる
Authenticating as test@example.com ...
Error authenticating to IdP.: error loading first page: failed to build login form data: could not find any forms matching the provided IDs

% SAML2AWS_IDP_PROVIDER=Browser saml2aws login --download-browser-driver
Using IdP Account default to access Browser https://accounts.google.com/o/saml2/initsso?idpid=******&spid=1234567890&forceauthn=false
To use saved password just hit enter.
? Username GoogleWorkspaceめあどいれる
? Password ぱすわーどいれる
Authenticating as test@example.com ...
INFO[0006] opening browser
URL="https://accounts.google.com/o/saml2/initsso?idpid=******&spid=1234567890&forceauthn=false" provider=browser
  • ブラウザが立ち上がるので、メアド入れましょう
    スクリーンショット 2024-06-17 12.07.01.png
  • 次は、パスワードです
    スクリーンショット 2024-06-17 12.07.18.png
  • 最後はスマホ認証
    スクリーンショット 2024-06-17 12.07.28.png
  • ログインできましたね
INFO[0008] waiting ...                                   provider=browser
INFO[0038] saving storage state                          provider=browser
INFO[0038] Error saving storage stateopen /Users/hogehoge/.aws/saml2aws/storageState.json: no such file or directory  provider=browser
INFO[0038] clean up browser                              provider=browser
Selected role: arn:aws:iam::1234567890:role/admin
Requesting AWS credentials using SAML assertion.
Logged in as: arn:aws:sts::1234567890:assumed-role/admin/test@example.com
Your new access key pair has been stored in the AWS configuration.
Note that it will expire at 2024-06-18 01:51:44 +0900 JST
To use this credential, call the AWS CLI with the --profile option

まとめ

  • aws-google-auth は更新もないし微妙です
  • saml2aws はブラウザモードで回避可能です
  • とりあえず、saml2aws を使うかという感じです・・・

参照

https://github.com/cevoaustralia/aws-google-auth
https://github.com/Versent/saml2aws/
https://github.com/Versent/saml2aws/issues/1259

We're hiring

絶賛、エンジニア(だけではなく)募集してます
カジュアル面談もやっていますので、お待ちしています

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0