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

1.42.0/auth #1221

Open
wants to merge 7 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
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
132 changes: 76 additions & 56 deletions content/develop/api-reference/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,29 @@ Display a horizontal rule.
st.divider()
```

</RefCard>
<RefCard href="/develop/api-reference/text/st.help">

<h4>Get help</h4>

Display object’s doc string, nicely formatted.

```python
st.help(st.write)
st.help(pd.DataFrame)
```

</RefCard>
<RefCard href="/develop/api-reference/text/st.html">

<h4>Render HTML</h4>

Renders HTML strings to your app.

```python
st.html("<p>Foo bar.</p>")
```

</RefCard>
</TileContainer>

Expand Down Expand Up @@ -1891,6 +1914,59 @@ rain(emoji="🎈", font_size=54,

## App logic and configuration

### Authentication and user info

<br />

<TileContainer>
<RefCard href="/develop/api-reference/user/st.context">

<h4>Context</h4>

`st.context` provides a read-only interface to access cookies and headers.

```python
st.context.cookies
st.context.headers
```

</RefCard>
<RefCard href="/develop/api-reference/user/st.login">

<h4>Log in a user</h4>

`st.login()` starts an authentication flow with an identity provider.

```python
st.login()
```

</RefCard>
<RefCard href="/develop/api-reference/user/st.logout">

<h4>Log out a user</h4>

`st.logout` removes a user's identity information.

```python
st.logout()
```

</RefCard>
<RefCard href="/develop/api-reference/user/st.user" size="full">

<h4>User info</h4>

`st.experimental_user` returns information about a logged-in user.

```python
if st.experimental_user.is_logged_in:
st.write(f"Welcome back, {st.experimental_user.name}!")
```

</RefCard>
</TileContainer>

### Navigation and pages

<br />
Expand Down Expand Up @@ -2370,62 +2446,6 @@ iframe(

</TileContainer>

### Utilities and user info

<br />

<TileContainer>
<RefCard href="/develop/api-reference/utilities/st.context">

<h4>Context</h4>

`st.context` provides a read-only interface to access cookies and headers.

```python
st.context.cookies
st.context.headers
```

</RefCard>
<RefCard href="/develop/api-reference/utilities/st.help">

<h4>Get help</h4>

Display object’s doc string, nicely formatted.

```python
st.help(st.write)
st.help(pd.DataFrame)
```

</RefCard>
<RefCard href="/develop/api-reference/utilities/st.html">

<h4>Render HTML</h4>

Renders HTML strings to your app.

```python
st.html("<p>Foo bar.</p>")
```

</RefCard>
<RefCard href="/develop/api-reference/utilities/st.experimental_user" size="full">

<h4>User info</h4>

`st.experimental_user` returns information about the logged-in user of private apps on Streamlit Community Cloud.

```python
if st.experimental_user.email == "[email protected]":
st.write("Welcome back, ", st.experimental_user.email)
else:
st.write("You are not authorized to view this page.")
```

</RefCard>
</TileContainer>

### Configuration

<br />
Expand Down
28 changes: 28 additions & 0 deletions content/develop/api-reference/text/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ st.divider()
</RefCard>
</TileContainer>

## Utilities

<TileContainer>
<RefCard href="/develop/api-reference/text/st.help" size="half">

<h4>Get help</h4>

Display object’s doc string, nicely formatted.

```python
st.help(st.write)
st.help(pd.DataFrame)
```

</RefCard>
<RefCard href="/develop/api-reference/text/st.html" size="half">

<h4>Render HTML</h4>

Renders HTML strings to your app.

```python
st.html("<p>Foo bar.</p>")
```

</RefCard>
</TileContainer>

<ComponentSlider>
<ComponentCard href="https://github.com/tvst/st-annotated-text">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: st.help
slug: /develop/api-reference/utilities/st.help
slug: /develop/api-reference/text/st.help
description: st.help displays object's doc string, nicely formatted.
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: st.html
slug: /develop/api-reference/utilities/st.html
slug: /develop/api-reference/text/st.html
description: st.html renders arbitrary HTML strings to your app
---

Expand Down
58 changes: 58 additions & 0 deletions content/develop/api-reference/user/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Authentication and user info
slug: /develop/api-reference/user
---

# Authentication & user info

There are a handful of methods that allow you to create placeholders in your
app, provide help using doc strings, get and modify configuration options and query parameters.

<TileContainer>
<RefCard href="/develop/api-reference/utilities/st.context">

<h4>Context</h4>

`st.context` provides a read-only interface to access cookies and headers.

```python
st.context.cookies
st.context.headers
```

</RefCard>
<RefCard href="/develop/api-reference/user/st.login">

<h4>Log in a user</h4>

`st.login()` starts an authentication flow with an identity provider.

```python
st.login()
```

</RefCard>
<RefCard href="/develop/api-reference/user/st.logout">

<h4>Log out a user</h4>

`st.logout` removes a user's identity information.

```python
st.logout()
```

</RefCard>
<RefCard href="/develop/api-reference/utilities/st.user" size="full">

<h4>User info</h4>

`st.experimental_user` returns information about a logged-in user.

```python
if st.experimental_user.is_logged_in:
st.write(f"Welcome back, {st.experimental_user.name}!")
```

</RefCard>
</TileContainer>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: st.context
slug: /develop/api-reference/utilities/st.context
slug: /develop/api-reference/user/st.context
description: st.context displays a read-only dict of cookies and headers
---

Expand Down
7 changes: 7 additions & 0 deletions content/develop/api-reference/user/login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: st.login
slug: /develop/api-reference/user/st.login
description: st.login redirects the user to the configured authentication provider to log in.
---

<Autofunction function="streamlit.login" />
7 changes: 7 additions & 0 deletions content/develop/api-reference/user/logout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: st.logout
slug: /develop/api-reference/user/st.logout
description: st.logout removes the user's identity information and starts a clean session.
---

<Autofunction function="streamlit.logout" />
21 changes: 21 additions & 0 deletions content/develop/api-reference/user/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: st.user
slug: /develop/api-reference/user/st.user
description: st.experimental_user returns information about the logged-in user of private apps on Streamlit Community Cloud.
---

<Important>

This is an experimental feature. Experimental features and their APIs may change or be removed at any time. To learn more, click [here](/develop/quick-reference/prerelease#experimental-features).

</Important>

<Autofunction function="streamlit.experimental_user" />

### Community Cloud

On Community Cloud, if your app is not configured for authentication, `st.experimental_user` will have a single attribute: `email`. If a user is logged in and a member of your app's workspace, this will return the user's email. For all other cases, it returns `None`.

On Community Cloud, if your app is configured for authentication (`[auth]` exists in your app's secrets), `st.experimental_user` will behave the same as a locally running app. Remember to update your identity provider's configuration and your app's secrets to allow your new domain. A list of [IP addresses](/deploy/streamlit-community-cloud/status#ip-addresses) used by Community Cloud is available if needed. An authentication-configured app counts as your one, allowed private app.

<Autofunction function="streamlit.experimental_user.to_dict" />
61 changes: 0 additions & 61 deletions content/develop/api-reference/utilities/_index.md

This file was deleted.

Loading