-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Expose AnonymousAccess service through Security OSS plugin. #87091
Merged
azasypkin
merged 15 commits into
elastic:master
from
azasypkin:issue-83650-anonymous-improve-ux
Jan 15, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ad82f4c
Expose AnonymousAccess service through Security OSS plugin.
azasypkin 27ee6d1
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin 4a77cfb
Review#1: invert implicit OSS plugin dependency on X-Pack.
azasypkin 1d4b394
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin 0fad3e6
Review#1: use capabilities API to check if anonymous service account …
azasypkin f77a4f5
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin 2277675
Review#2: fix and write tests, handle review feedback.
azasypkin bc7f9b1
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin b0e2624
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin e877c5b
Minor tweaks and integration tests.
azasypkin bf71e3c
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin ea31566
Review#3: handle review nits and adjust anonymous access tests for th…
azasypkin db91b20
Merge branch 'master' into issue-83650-anonymous-improve-ux
kibanamachine e166855
Merge branch 'master' into issue-83650-anonymous-improve-ux
azasypkin 35d89ad
Review#3: handle review nits.
azasypkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...development/core/server/kibana-plugin-core-server.resolvecapabilitiesoptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ResolveCapabilitiesOptions](./kibana-plugin-core-server.resolvecapabilitiesoptions.md) | ||
|
||
## ResolveCapabilitiesOptions interface | ||
|
||
Defines a set of additional options for the `resolveCapabilities` method of [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md)<!-- -->. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface ResolveCapabilitiesOptions | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [useDefaultCapabilities](./kibana-plugin-core-server.resolvecapabilitiesoptions.usedefaultcapabilities.md) | <code>boolean</code> | Indicates if capability switchers are supposed to return a default set of capabilities. | | ||
|
13 changes: 13 additions & 0 deletions
13
.../kibana-plugin-core-server.resolvecapabilitiesoptions.usedefaultcapabilities.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ResolveCapabilitiesOptions](./kibana-plugin-core-server.resolvecapabilitiesoptions.md) > [useDefaultCapabilities](./kibana-plugin-core-server.resolvecapabilitiesoptions.usedefaultcapabilities.md) | ||
|
||
## ResolveCapabilitiesOptions.useDefaultCapabilities property | ||
|
||
Indicates if capability switchers are supposed to return a default set of capabilities. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
useDefaultCapabilities: boolean; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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. | ||
*/ | ||
|
||
/** | ||
* Defines Security OSS application state. | ||
*/ | ||
export interface AppState { | ||
insecureClusterAlert: { displayAlert: boolean }; | ||
anonymousAccess: { | ||
isEnabled: boolean; | ||
accessURLParameters: Record<string, string> | null; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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. | ||
*/ | ||
|
||
export type { AppState } from './app_state'; |
32 changes: 32 additions & 0 deletions
32
src/plugins/security_oss/public/app_state/app_state_service.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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. | ||
*/ | ||
|
||
import type { AppState } from '../../common'; | ||
import type { AppStateServiceStart } from './app_state_service'; | ||
|
||
export const mockAppStateService = { | ||
createStart: (): jest.Mocked<AppStateServiceStart> => { | ||
return { getState: jest.fn() }; | ||
}, | ||
createAppState: (appState: Partial<AppState> = {}) => ({ | ||
insecureClusterAlert: { displayAlert: false }, | ||
anonymousAccess: { isEnabled: false, accessURLParameters: null }, | ||
...appState, | ||
}), | ||
}; |
72 changes: 72 additions & 0 deletions
72
src/plugins/security_oss/public/app_state/app_state_service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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. | ||
*/ | ||
|
||
import { coreMock } from '../../../../core/public/mocks'; | ||
import { AppStateService } from './app_state_service'; | ||
|
||
describe('AppStateService', () => { | ||
describe('#start', () => { | ||
it('returns default state for the anonymous routes', async () => { | ||
const coreStart = coreMock.createStart(); | ||
coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(true); | ||
|
||
const appStateService = new AppStateService(); | ||
await expect(appStateService.start({ core: coreStart }).getState()).resolves.toEqual({ | ||
insecureClusterAlert: { displayAlert: false }, | ||
anonymousAccess: { isEnabled: false, accessURLParameters: null }, | ||
}); | ||
|
||
expect(coreStart.http.get).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('returns default state if current state cannot be retrieved', async () => { | ||
const coreStart = coreMock.createStart(); | ||
coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); | ||
|
||
const failureReason = new Error('Uh oh.'); | ||
coreStart.http.get.mockRejectedValue(failureReason); | ||
|
||
const appStateService = new AppStateService(); | ||
await expect(appStateService.start({ core: coreStart }).getState()).resolves.toEqual({ | ||
insecureClusterAlert: { displayAlert: false }, | ||
anonymousAccess: { isEnabled: false, accessURLParameters: null }, | ||
}); | ||
|
||
expect(coreStart.http.get).toHaveBeenCalledTimes(1); | ||
expect(coreStart.http.get).toHaveBeenCalledWith('/internal/security_oss/app_state'); | ||
}); | ||
|
||
it('returns retrieved state', async () => { | ||
const coreStart = coreMock.createStart(); | ||
coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); | ||
|
||
const state = { | ||
insecureClusterAlert: { displayAlert: true }, | ||
anonymousAccess: { isEnabled: true, accessURLParameters: { hint: 'some-hint' } }, | ||
}; | ||
coreStart.http.get.mockResolvedValue(state); | ||
|
||
const appStateService = new AppStateService(); | ||
await expect(appStateService.start({ core: coreStart }).getState()).resolves.toEqual(state); | ||
|
||
expect(coreStart.http.get).toHaveBeenCalledTimes(1); | ||
expect(coreStart.http.get).toHaveBeenCalledWith('/internal/security_oss/app_state'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
note: couldn't find a better name for that service, data and endpoint, kind of analogy with ASP.NET view state, but happy to take any other name if you have suggestions.
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.
I'm fine with
AppState
here. That makes sense to me