openid / openid/AppAuth-iOS

Owner password flow using OIDTokenRequest crashes on token refresh

Open
#593 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C
Stars
2k
Forks
867
Avg merge
4d 48m
Merged PRs (30d)
1

Description

We support both Owner Password Flow, along with Authorization Code flow. I've wrapped our request layer with authState.performAction(freshTokens:). However, because I use OIDTokenRequest directly for the password flow, and call OIDAuthorizationService.perform(_: OIDTokenRequest, callback: OIDTokenCallback), AppAuth crashes in OIDTokenRequest.m on [bodyParameters addParameter:kClientIDKey value:_clientID]; since _clientID is nil.

Am I doing something wrong or not setting something I should be? Is password flow not officially supported?

Here's my password flow code snippet:

// Log in with username/pwd
OIDAuthorizationService.discoverConfiguration(forIssuer: issuer) { [weak self] configuration, error in
            guard let self = self, let config = configuration else {
                completion(.failure(AppAuthError.invalid))
                return
            }
            let request = OIDTokenRequest(configuration: config,
                                          grantType: OIDGrantTypePassword,
                                          authorizationCode: nil,
                                          redirectURL: redirectURL,
                                          clientID: clientID,
                                          clientSecret: nil,
                                          scope: OIDScopeOpenID,
                                          refreshToken: self.authState?.lastTokenResponse?.refreshToken,
                                          codeVerifier: nil,
                                          additionalParameters: ["username": username,
                                                                 "password": password])

            OIDAuthorizationService.perform(request) { [weak self] tokenResponse, error in
                guard let self = self else {
                    completion(.failure(AppAuthError.invalid))
                    return
                }

                if let tokenResponse = tokenResponse {
                    self.authState = OIDAuthState(authorizationResponse: nil,
                                                  tokenResponse: tokenResponse,
                                                  registrationResponse: nil)
               
                ...
                // continue on doing things

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in OIDTokenRequest.m at the [bodyParameters addParameter:kClientIDKey value:_clientID] crash and trace the OIDAuthorizationService.perform path used by the password-flow snippet. Determine whether token refresh supports this request type and whether the supplied clientID reaches the request; done means the supported behavior and required configuration are established without the reported crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, swift
Domain
authentication, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.