Skip to content

Commit 69bc5c4

Browse files
Release 1.45.0 (#1284)
* Update streamlit.json * New st.context properties * De-experimentalize st.user * Release notes * What's new & cheat sheet * Bump embedded apps to latest * Linting * Update pages/index.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Correction --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dc65e08 commit 69bc5c4

File tree

32 files changed

+11282
-147
lines changed

32 files changed

+11282
-147
lines changed

content/develop/api-reference/_index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,11 +1958,11 @@ st.logout()
19581958

19591959
<h4>User info</h4>
19601960

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

19631963
```python
1964-
if st.experimental_user.is_logged_in:
1965-
st.write(f"Welcome back, {st.experimental_user.name}!")
1964+
if st.user.is_logged_in:
1965+
st.write(f"Welcome back, {st.user.name}!")
19661966
```
19671967

19681968
</RefCard>
@@ -2234,7 +2234,7 @@ st.query_params.clear()
22342234

22352235
<h4>Context</h4>
22362236

2237-
`st.context` provides a read-only interface to access cookies and headers.
2237+
`st.context` provides a read-only interface to access cookies, headers, locale, and other browser-session information.
22382238

22392239
```python
22402240
st.context.cookies

content/develop/api-reference/caching-and-state/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Streamlit re-executes your script with each user interaction. Widgets have built
5858

5959
<h4>Context</h4>
6060

61-
`st.context` provides a read-only interface to access cookies and headers.
61+
`st.context` provides a read-only interface to access cookies, headers, locale, and other browser-session information.
6262

6363
```python
6464
st.context.cookies

content/develop/api-reference/caching-and-state/context.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ description: st.context displays a read-only dict of cookies and headers
1010

1111
<Autofunction function="context.headers" />
1212

13+
<Autofunction function="context.ip_address" />
14+
15+
<Autofunction function="context.is_embedded" />
16+
1317
<Autofunction function="context.locale" />
1418

1519
<Autofunction function="context.timezone" />
1620

1721
<Autofunction function="context.timezone_offset" />
22+
23+
<Autofunction function="context.url" />

content/develop/api-reference/user/_index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ st.logout()
3434

3535
<h4>User info</h4>
3636

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

3939
```python
40-
if st.experimental_user.is_logged_in:
41-
st.write(f"Welcome back, {st.experimental_user.name}!")
40+
if st.user.is_logged_in:
41+
st.write(f"Welcome back, {st.user.name}!")
4242
```
4343

4444
</RefCard>
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
---
22
title: st.user
33
slug: /develop/api-reference/user/st.user
4-
description: st.experimental_user returns information about the logged-in user of private apps on Streamlit Community Cloud.
4+
description: st.user returns information about the logged-in user of private apps on Streamlit Community Cloud.
55
---
66

7-
<Important>
8-
9-
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).
10-
11-
</Important>
12-
13-
<Autofunction function="streamlit.experimental_user" />
7+
<Autofunction function="streamlit.user" oldName="streamlit.experimental_user" />
148

159
### Community Cloud
1610

17-
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`.
11+
On Community Cloud, if your app is not configured for authentication, `st.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`.
1812

19-
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.
13+
On Community Cloud, if your app is configured for authentication (`[auth]` exists in your app's secrets), `st.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.
2014

21-
<Autofunction function="streamlit.experimental_user.to_dict" />
15+
<Autofunction function="streamlit.user.to_dict" oldName="streamlit.experimental_user.to_dict" />

content/develop/concepts/connections/authentication.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ Some popular OIDC providers are:
2222
- [Okta](https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_oidc.htm)
2323
- [Auth0](https://auth0.com/docs/get-started/auth0-overview/create-applications/regular-web-apps)
2424

25-
## `st.login()`, `st.experimental_user`, and `st.logout()`
25+
## `st.login()`, `st.user`, and `st.logout()`
2626

2727
There are three commands involved with user authentication:
2828

2929
- [`st.login()`](/develop/api-reference/user/st.login) redirects the user to your identity provider. After they log in, Streamlit stores an identity cookie and then redirects them to the homepage of your app in a new session.
30-
- [`st.experimental_user`](/develop/api-reference/user/st.user) is a dict-like object for accessing user information. It has a persistent attribute, `.is_logged_in`, which you can check for the user's login status. When they are logged in, other attributes are available per your identity provider's configuration.
30+
- [`st.user`](/develop/api-reference/user/st.user) is a dict-like object for accessing user information. It has a persistent attribute, `.is_logged_in`, which you can check for the user's login status. When they are logged in, other attributes are available per your identity provider's configuration.
3131
- [`st.logout()`](/develop/api-reference/user/st.logout) removes the identity cookie from the user's browser and redirects them to the homepage of your app in a new session.
3232

3333
## User cookies and logging out
3434

35-
Streamlit checks for the identity cookie at the beginning of each new session. If a user logs in to your app in one tab and then opens a new tab, they will automatically be logged in to your app in the new tab. When you call `st.logout()` in a user session, Streamlit removes the identity cookie and starts a new session. This logs the user out from the current session. However, if they were logged in to other sessions already, they will remain logged in within those sessions. The information in `st.experimental_user` is updated at the beginning of a session (which is why `st.login()` and `st.logout()` both start new sessions after saving or deleting the identity cookie).
35+
Streamlit checks for the identity cookie at the beginning of each new session. If a user logs in to your app in one tab and then opens a new tab, they will automatically be logged in to your app in the new tab. When you call `st.logout()` in a user session, Streamlit removes the identity cookie and starts a new session. This logs the user out from the current session. However, if they were logged in to other sessions already, they will remain logged in within those sessions. The information in `st.user` is updated at the beginning of a session (which is why `st.login()` and `st.logout()` both start new sessions after saving or deleting the identity cookie).
3636

37-
If a user closes your app without logging out, the identity cookie will expire after 30 days. This expiration time is not configurable and is not tied to any expiration time that may be returned in your user's identity token. If you need to prevent persistent authentication in your app, check the expiration information returned by the identity provider in `st.experimental_user` and manually call `st.logout()` when needed.
37+
If a user closes your app without logging out, the identity cookie will expire after 30 days. This expiration time is not configurable and is not tied to any expiration time that may be returned in your user's identity token. If you need to prevent persistent authentication in your app, check the expiration information returned by the identity provider in `st.user` and manually call `st.logout()` when needed.
3838

3939
Streamlit does not modify or delete any cookies saved directly by your identity provider. For example, if you use Google as your identity provider and a user logs in to your app with Google, they will remain logged in to their Google account after they log out of your app with `st.logout()`.
4040

@@ -96,27 +96,27 @@ In your app, create a simple login flow:
9696
```python
9797
import streamlit as st
9898

99-
if not st.experimental_user.is_logged_in:
99+
if not st.user.is_logged_in:
100100
if st.button("Log in with Google"):
101101
st.login()
102102
st.stop()
103103

104104
if st.button("Log out"):
105105
st.logout()
106-
st.markdown(f"Welcome! {st.experimental_user.name}")
106+
st.markdown(f"Welcome! {st.user.name}")
107107
```
108108

109109
When you use `st.stop()`, your script run ends as soon as the login button is displayed. This lets you avoid nesting your entire page within a conditional block. Additionally, you can use callbacks to simplify the code further:
110110

111111
```python
112112
import streamlit as st
113113

114-
if not st.experimental_user.is_logged_in:
114+
if not st.user.is_logged_in:
115115
st.button("Log in with Google", on_click=st.login)
116116
st.stop()
117117

118118
st.button("Log out", on_click=st.logout)
119-
st.markdown(f"Welcome! {st.experimental_user.name}")
119+
st.markdown(f"Welcome! {st.user.name}")
120120
```
121121

122122
## Using multiple OIDC providers
@@ -152,7 +152,7 @@ Your app code:
152152
```python
153153
import streamlit as st
154154

155-
if not st.experimental_user.is_logged_in:
155+
if not st.user.is_logged_in:
156156
if st.button("Log in with Google"):
157157
st.login("google")
158158
if st.button("Log in with Microsoft"):
@@ -161,21 +161,21 @@ if not st.experimental_user.is_logged_in:
161161

162162
if st.button("Log out"):
163163
st.logout()
164-
st.markdown(f"Welcome! {st.experimental_user.name}")
164+
st.markdown(f"Welcome! {st.user.name}")
165165
```
166166

167167
Using callbacks, this would look like:
168168

169169
```python
170170
import streamlit as st
171171

172-
if not st.experimental_user.is_logged_in:
172+
if not st.user.is_logged_in:
173173
st.button("Log in with Google", on_click=st.login, args=["google"])
174174
st.button("Log in with Microsoft", on_click=st.login, args=["microsoft"])
175175
st.stop()
176176

177177
st.button("Log out", on_click=st.logout)
178-
st.markdown(f"Welcome! {st.experimental_user.name}")
178+
st.markdown(f"Welcome! {st.user.name}")
179179
```
180180

181181
## Passing keywords to your identity provider

content/develop/quick-references/api-cheat-sheet.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ slug: /develop/quick-reference/cheat-sheet
55

66
# Streamlit API cheat sheet
77

8-
This is a summary of the docs for the latest version of Streamlit, [v1.44.0](https://pypi.org/project/streamlit/1.44.0/).
8+
This is a summary of the docs for the latest version of Streamlit, [v1.45.0](https://pypi.org/project/streamlit/1.45.0/).
99

1010
<Masonry>
1111

@@ -513,17 +513,20 @@ st.exception(e)
513513

514514
```python
515515
# Authenticate users
516-
if not st.experimental_user.is_logged_in:
516+
if not st.user.is_logged_in:
517517
st.login("my_provider")
518-
f"Hi, {st.experimental_user.name}"
518+
f"Hi, {st.user.name}"
519519
st.logout()
520520

521-
# Get dictionaries of cookies and headers
521+
# Get dictionaries of cookies, headers, locale, and browser data
522522
st.context.cookies
523523
st.context.headers
524+
st.context.ip_address
525+
st.context.is_embedded
524526
st.context.locale
525527
st.context.timezone
526528
st.context.timezone_offset
529+
st.context.url
527530
```
528531

529532
</CodeTile>

0 commit comments

Comments
 (0)