Skip to content

HA: use and authenticate with multiple controllers#686

Merged
ekoby merged 4 commits intomainfrom
ha-ctrl
Apr 30, 2025
Merged

HA: use and authenticate with multiple controllers#686
ekoby merged 4 commits intomainfrom
ha-ctrl

Conversation

@ekoby
Copy link
Copy Markdown
Member

@ekoby ekoby commented Apr 29, 2025

Enable SDK to work with an HA OpenZiti network:

  • discover available controllers
  • pick controller that is currently online
  • use internal OIDC for authentication

@ekoby ekoby requested a review from a team as a code owner April 29, 2025 18:05
@ekoby ekoby added the minor bumps minor rev label Apr 29, 2025
e("failed to login, cannot continue")
updateStatus(ZitiContext.Status.NotAuthorized(it))
throw it
val c = Retry.withExponentialBackoff {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pointing out that it seems a bit strange to have a while(true) when the withExponentialBackoff func runs forever? Maybe it makes sense to do all of this in the same lambda?

Copy link
Copy Markdown
Member Author

@ekoby ekoby Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exponential backoff is only for finding a controller that is online

there is no reason to do a backoff if selected controller went offline

}

internal inner class ReqInterceptor(val session: ApiSession? = null): Consumer<HttpRequest.Builder> {
internal inner class ReqInterceptor(val accessToken: ZitiAuthenticator.ZitiAccessToken): Consumer<HttpRequest.Builder> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessToken seems a bit like a misnomer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a token that gives access, no?


companion object {
const val CLIENT_ID = "openziti"
const val internalRedirect = "http://localhost:8080/auth/callback"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i assume this is just hardcoded by the controller or there's no redirect uri matching?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is hardcoded in controller


val redirectUri = resp.headers().firstValue("Location").get().run { URI.create(this) }

val query = redirectUri.query.split("&").associate {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no helper func for this eh? strange!

@ekoby ekoby merged commit a5c0256 into main Apr 30, 2025
16 of 17 checks passed
@ekoby ekoby deleted the ha-ctrl branch April 30, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor bumps minor rev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants