Skip to content

add simple identity registry and registry-based authorizer#1988

Merged
crazytan merged 2 commits intoistio:masterfrom
crazytan:registry
Dec 5, 2017
Merged

add simple identity registry and registry-based authorizer#1988
crazytan merged 2 commits intoistio:masterfrom
crazytan:registry

Conversation

@crazytan
Copy link
Copy Markdown
Contributor

@crazytan crazytan commented Dec 5, 2017

What this PR does / why we need it:
This PR adds identity registry support for service accounts registered via istioctl register command. istioctl register has -s option to specify the service account to be linked to the service. By adding a service controller to listen to such changes (see #1951), the identity registry automatically adds new service accounts to the mapping (effectively a whitelist).

It also adds registryAuthorizor that consults identity registry for authorization decisions. When used by CA, the identity in the CSR sent by node agent needs to be in the registry to be signed by CA.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #1976

Special notes for your reviewer: There's no integration tests for this. Need to wait for #625. Also it's not enabled by default yet.

Release note:

NONE

Copy link
Copy Markdown
Contributor

@wattli wattli left a comment

Choose a reason for hiding this comment

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

Thanks, a few minor comments.

}

// IdentityRegistry is a naive registry that maintains a mapping between
// identities (as strings)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Explains a little bit more about the mapping between identites?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

return reg
}

// K8SServiceAdded ...
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Finish the comment? Same below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry I forgot... Will add comments

mapped, ok := reg.Map[id1]
reg.RUnlock()
if !ok {
return false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we log some info here for debugging purpose? And if possible, please also log the case that mapped existed, but not equal to id2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

}

// registryAuthorizor uses an underlying identity registry to make authorization decisions
type registryAuthorizor struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So there will be another PR to hook up the Control Plane with this registryAuthorizor, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure whether to add a cmd option to let user select which authorizor to use, or just switch to registryAuthorizor by default (for this I need to ensure that existing mesh expansion script works fine).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The current one is pretty dummy and we should replace it. It would be great to provide an option for user to select once we have more complete authorizors. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in a follow up PR :)

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 5, 2017

Codecov Report

Merging #1988 into master will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1988      +/-   ##
==========================================
- Coverage   81.81%   81.69%   -0.13%     
==========================================
  Files         190      195       +5     
  Lines       15675    16020     +345     
==========================================
+ Hits        12825    13087     +262     
- Misses       2414     2459      +45     
- Partials      436      474      +38
Flag Coverage Δ
#broker 47.27% <ø> (ø) ⬆️
#mixer 83.08% <ø> (-0.27%) ⬇️
#pilot 80.75% <ø> (+0.17%) ⬆️
#security 88.82% <ø> (-3.21%) ⬇️
Impacted Files Coverage Δ
mixer/adapter/stackdriver/helper/common.go 66.66% <0%> (-8.34%) ⬇️
mixer/pkg/expr/func.go 93.93% <0%> (-6.07%) ⬇️
mixer/adapter/svcctrl/distValueBuilder.go 87.5% <0%> (-4.34%) ⬇️
mixer/pkg/cache/ttlCache.go 98.07% <0%> (-1.93%) ⬇️
mixer/adapter/svcctrl/checkprocessor.go 77.77% <0%> (-1.68%) ⬇️
mixer/pkg/expr/expr.go 93.92% <0%> (-1.26%) ⬇️
mixer/pkg/cache/lruCache.go 99.01% <0%> (-0.99%) ⬇️
mixer/pkg/il/runtime/externs.go 95.45% <0%> (-0.98%) ⬇️
mixer/adapter/svcctrl/reportbuilder.go 88.57% <0%> (-0.11%) ⬇️
mixer/pkg/il/compiler/compiler.go 88.84% <0%> (-0.09%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 620a7c7...4233da0. Read the comment docs.

Copy link
Copy Markdown
Contributor

@wattli wattli left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

}

// registryAuthorizor uses an underlying identity registry to make authorization decisions
type registryAuthorizor struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The current one is pretty dummy and we should replace it. It would be great to provide an option for user to select once we have more complete authorizors. :)

}

// registryAuthorizor uses an underlying identity registry to make authorization decisions
type registryAuthorizor struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in a follow up PR :)

@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wattli

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add identity registry support for service accounts registered via istioctl register

5 participants