-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates for #6911 and #6918 #1131
base: master
Are you sure you want to change the base?
Changes from 3 commits
fef018e
08ec1ef
026ad25
df29277
683d0fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import com.netflix.spinnaker.kork.web.exceptions.ExceptionMessageDecorator; | ||
import com.netflix.spinnaker.okhttp.SpinnakerRequestInterceptor; | ||
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger; | ||
import com.netflix.spinnaker.security.SpinnakerUsers; | ||
import lombok.Setter; | ||
import lombok.val; | ||
import okhttp3.OkHttpClient; | ||
|
@@ -143,6 +144,8 @@ protected void configure(HttpSecurity http) throws Exception { | |
.exceptionHandling() | ||
.and() | ||
.anonymous() | ||
// match the same anonymous userid as expected elsewhere | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this different from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default settings in this DSL set the principal to the string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So using the updated Spring Security DSL, this whole method would look more like the following: http.servletApi(Customizer.withDefaults())
.exceptionHandling(Customizer.withDefaults())
.anonymous(anonymous -> anonymous.principal(SpinnakerUsers.ANONYMOUS))
.addFilterBefore(
new FiatAuthenticationFilter(fiatStatus, authenticationConverter),
AnonymousAuthenticationFilter.class); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll figure out some sort of test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out testing this is futile. I've extracted some constants to make this more consistent. |
||
.principal(SpinnakerUsers.ANONYMOUS) | ||
.and() | ||
.addFilterBefore( | ||
new FiatAuthenticationFilter(fiatStatus, authenticationConverter), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2024 Apple, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.fiat.shared | ||
|
||
import com.netflix.spinnaker.fiat.model.AuthorizationMapControlled | ||
import com.netflix.spinnaker.fiat.model.resources.Permissions | ||
|
||
class PermissionsControlledResource implements AuthorizationMapControlled { | ||
Permissions.Builder permissions = new Permissions.Builder() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2023 Apple, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.netflix.spinnaker.fiat.model; | ||
|
||
import com.netflix.spinnaker.security.PermissionMapControlled; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Common interface for access-controlled classes which use a permission map of {@link | ||
* Authorization} enums. | ||
*/ | ||
public interface AuthorizationMapControlled extends PermissionMapControlled<Authorization> { | ||
@Nullable | ||
@Override | ||
default Authorization valueOf(@Nullable Object authorization) { | ||
return Authorization.parse(authorization); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notes for reviewers -- the new code looks like it does exactly the same thing as the old code, so this is "just" a refactor.