@@ -26,7 +26,7 @@ module PlaceOS::Api
2626 version : TokenVersion ,
2727 kid : String ? do
2828 # Basic heuristic to detect Microsoft Entra / Azure AD issuers
29- def is_ms_token ? : Bool
29+ def ms_token ? : Bool
3030 iss_val = iss_host
3131 return false unless iss_val
3232 iss_val = iss_val.downcase
@@ -119,14 +119,14 @@ module PlaceOS::Api
119119
120120 # if not existing or refresh failed, get a token using this token and on behalf of
121121 # https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-on-behalf-of-flow#example
122- form = URI ::Params .build do |form |
123- form .add " grant_type" , " urn:ietf:params:oauth:grant-type:jwt-bearer"
124- form .add " client_id" , oauth.client_id
125- form .add " client_secret" , oauth.client_secret
126- form .add " assertion" , token
127- form .add " scope" , oauth.scope
128- form .add " requested_token_use" , " on_behalf_of"
129- form .add " resource" , " https://graph.microsoft.com/"
122+ form = URI ::Params .build do |builder |
123+ builder .add " grant_type" , " urn:ietf:params:oauth:grant-type:jwt-bearer"
124+ builder .add " client_id" , oauth.client_id
125+ builder .add " client_secret" , oauth.client_secret
126+ builder .add " assertion" , token
127+ builder .add " scope" , oauth.scope
128+ builder .add " requested_token_use" , " on_behalf_of"
129+ builder .add " resource" , " https://graph.microsoft.com/"
130130 end
131131
132132 uri = token_info.token_endpoint
@@ -163,23 +163,19 @@ module PlaceOS::Api
163163 # ---------- Audience Parsing ----------
164164
165165 def extract_aud_host (aud_raw : String ) : String
166- begin
167- uri = URI .parse(aud_raw)
168- uri.host || aud_raw
169- rescue
170- aud_raw
171- end
166+ uri = URI .parse(aud_raw)
167+ uri.host || aud_raw
168+ rescue
169+ aud_raw
172170 end
173171
174172 # ---------- Issuer Parsing ----------
175173
176174 def extract_issuer_host (iss_raw : String ) : String ?
177- begin
178- uri = URI .parse(iss_raw)
179- uri.host
180- rescue
181- nil
182- end
175+ uri = URI .parse(iss_raw)
176+ uri.host
177+ rescue
178+ nil
183179 end
184180
185181 # ---------- Validation (JWKS) ----------
0 commit comments