This repository was archived by the owner on Jan 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ struct TokenRequest<'a> {
4242#[ derive( Deserialize , Debug ) ]
4343struct TokenResponse {
4444 access_token : String ,
45+ id_token : Option < String > ,
4546}
4647
4748impl Concourse {
@@ -59,6 +60,33 @@ impl Concourse {
5960 }
6061
6162 pub ( crate ) fn auth ( mut self , username : & str , password : & str ) -> Self {
63+ if let Ok ( token) = reqwest:: Url :: parse ( & format ! ( "{}sky/issuer/token" , self . url) )
64+ . map_err ( |_| ( ) )
65+ . and_then ( |url| {
66+ self . client
67+ . clone ( )
68+ . expect ( "error configuring HTTP client" )
69+ . post ( url)
70+ . basic_auth ( "fly" , Some ( "Zmx5" ) )
71+ . form ( & TokenRequest {
72+ grant_type : "password" ,
73+ username,
74+ password,
75+ scope : "openid profile email groups federated:id" ,
76+ } )
77+ . send ( )
78+ . map_err ( |_| ( ) )
79+ . and_then ( |req| req. json :: < TokenResponse > ( ) . map_err ( |_| ( ) ) )
80+ } )
81+ {
82+ self . bearer = token. id_token ;
83+ } else {
84+ self = self . old_auth ( username, password) ;
85+ }
86+ self
87+ }
88+
89+ pub ( crate ) fn old_auth ( mut self , username : & str , password : & str ) -> Self {
6290 if let Ok ( token) = reqwest:: Url :: parse ( & format ! ( "{}sky/token" , self . url) )
6391 . map_err ( |_| ( ) )
6492 . and_then ( |url| {
You can’t perform that action at this time.
0 commit comments