Skip to content
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

fix(serviceAccounts): Wrap F50 call and guard with permissionService.… #417

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ class OAuth2SsoConfig {
String firstName = "given_name"
String lastName = "family_name"
String username = "email"
String serviceAccountEmail = "email"
String serviceAccountEmail = "client_email"
}

@Component
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication
import org.springframework.security.oauth2.provider.OAuth2Request
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken
import retrofit.RetrofitError

import java.util.regex.Pattern
import java.util.regex.PatternSyntaxException
@@ -120,11 +121,16 @@ class SpinnakerUserInfoTokenServices implements ResourceServerTokenServices {

boolean isServiceAccount(Map details) {
String email = details[userInfoMapping.serviceAccountEmail]
if (!email) {
if (!email || !permissionService.isEnabled()) {
return false
}
def serviceAccounts = front50Service.getServiceAccounts()
return serviceAccounts.find { email.equalsIgnoreCase(it.name)}
try {
def serviceAccounts = front50Service.getServiceAccounts()
return serviceAccounts.find { email.equalsIgnoreCase(it.name) }
} catch (RetrofitError re) {
log.warn("Could not get list of service accounts.", re)
}
return false
}

boolean hasAllUserInfoRequirements(Map details) {
Original file line number Diff line number Diff line change
@@ -42,6 +42,10 @@ class PermissionService {
@Autowired
FiatPermissionEvaluator permissionEvaluator

boolean isEnabled() {
return fiatConfig.enabled
}

void login(String userId) {
if (fiatConfig.enabled) {
fiatService.loginUser(userId, "")