Marvin (M123)
01/01/2023, 8:45 PMMartacus
01/01/2023, 9:40 PMEnter the issuer URL of your identity provider, commonly found in the issuer field of the Authorization Server’s well-known metadata endpoint.
Now it may be me not understanding correctly. But I cannot find any issuer URL on the supabase console. Nor do I see it in the docs. Is this how I'm supposed to authorize users? Now there is also the option to use code myself to authorize the request. Though I was hoping I wouldn't have to do that.
After reading some more I see that I may have to write a lambda that uses the secret to authorize my JWT tokens. Is that right?DirtyNative
01/01/2023, 10:15 PMMaark
01/01/2023, 10:19 PMclient.current_session
and client.current_user
, things look good. but when i then insert a row into a table with an RLS policy that only allows authenticated users to insert, it fails. here's the code:
# url is retrieved via gradio _js func, and then I s/#/?/ bc I think only url params, not url fragments, are supported here
supabase_client.auth.get_session_from_url(url = url, store_session = True)
supabase_client.table("curations_metadata").insert({"name": "test"}).execute()
I've also tried setting the session via client.set_session
and passing the refresh token that is found in the url fragment. I can again print out the session just fine, but can't seem to be able to INSERT with it.
i'm trying to insert a row that has a column with default value uid()
. When I change the RLS policy to allow anon
users, the insert works, but the user_id column is NULL.
any thoughts on why the supabase client isn't apparently sending an authenticated request for the insert?limonCoder
01/01/2023, 11:04 PMNin
01/02/2023, 12:20 AMjson
{
"code": "PGRST116",
"details": "Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row",
"hint": null,
"message": "JSON object requested, multiple (or no) rows returned"
}
How can this be?
Below is my code to retrieve the data:
javascript
return await supabaseClient
.from('intakes')
.select('id')
.eq('user_id', user?.id)
.maybeSingle()
thecoderatekid
01/02/2023, 12:34 AMSheprekt
01/02/2023, 2:05 AMteams
and team_members
. As you can expect, team_members
has a team_id
and a user_id
.
I want a user to be able to create a team, so I create a policy for insert
operations on the teams
table to just allow any authenticated users to create a team. Simple so far.
I set up a trigger to insert a team_members
record on the creation of a team. I almost want to bypass RLS here somehow though - because I also have a policy set on team_members
for ALL operations which allows users from a team to add other users to their team, providing they are already part of a team (in a function called get_teams_for_authenticated_user()
).
The issue here is that when my trigger on creating a team tries to insert a new team member, that user is not already a member of the team - violating the RLS policy on team_members
, and therefore not creating a new team member.
This is my first time putting this kind of logic in the DB instead of writing my own authz layer - so I'm trying to figure out how best to achieve this while learning at the same time, so it's possible my approach is completely wrong - but I am struggling to fit RLS into a multi-tenant style architecture.
Any advice appreciated!cohlar
01/02/2023, 4:52 AMtypescript
type DbTables = Database['public']['Tables'];
type TableName = keyof DbTables;
type DbInsert<T extends TableName> = DbTables[T]['Insert'];
async create<T extends TableName>(insertData: DbInsert<T> | DbInsert<T>[], resourceName: T) {
try {
const { data, error } = await supabase.from(resourceName).insert(insertData).select();
if (error) throw error;
return data;
} catch (error) {
console.error(error);
}
},
My generic indexed access operator isn't working as I was hoping... would anyone know how to make this work?
-- also posted on github for traceability, with additional details about the tables, types and error message: https://github.com/supabase/supabase/discussions/11398LearningJourney
01/02/2023, 5:50 AMItsEthra
01/02/2023, 6:01 AMclient.from('bucket').download('filename')
to fetch a file. But after I uploaded the file I changed the policies but I was still able to download the file? Then I deleted a file from a dashboard and even the bucket itself but nothing helped. I tried restarting docker containers but it didn't help either. The function above still returns Blob
data and null
error. What is happening and how do I fix it?Lois
01/02/2023, 7:39 AMOddman
01/02/2023, 7:58 AMdev Joakim Pedersen
01/02/2023, 9:10 AMRares | Foton • Teeps
01/02/2023, 9:47 AMakshatgggggg
01/02/2023, 10:45 AMWizzel
01/02/2023, 11:11 AMStorageException (StorageException(message: jwt expired, statusCode: 400, error: jwt expired))
even when I refresh the session with
dart
await Supabase.instance.client.auth.refreshSession();
before uploading.
Is this a bug or am I missing something?ŁukaszW.
01/02/2023, 11:40 AMCREATE POLICY
"Enable read access for public only published" ON public.apartments AS PERMISSIVE FOR
SELECT
TO anon USING ( (is_visible = true));
and still anon user can see rows with is_visible set to false.
I have applied some schema repairs found on GH issues, but with no luck,
Now I set up the pgtap test to check this, and the test fails so anon have access to the row.
Any help or direction to go now ?brassotron
01/02/2023, 1:13 PMiStun4Fun
01/02/2023, 1:51 PMSELECT 'streams' as metric, sum(quantity) as value, label_id
FROM royalties
JOIN music_labels
ON royalties.label_id = music_labels.id
WHERE music_labels.owner = 'da9c6981-5382-4809-af0f-bc324bbc589a'
AND royalties.type = 'streaming'
GROUP BY label_id
UNION ALL
SELECT 'downloads' as metric, sum(quantity) as value, label_id
FROM royalties
JOIN music_labels
ON royalties.label_id = music_labels.id
WHERE music_labels.owner = 'da9c6981-5382-4809-af0f-bc324bbc589a'
AND royalties.type = 'download'
GROUP BY label_id
UNION ALL
SELECT 'total_revenue' as metric, SUM(royalties.total_revenue) as value, label_id
FROM royalties
JOIN music_labels
ON royalties.label_id = music_labels.id
WHERE music_labels.owner = 'da9c6981-5382-4809-af0f-bc324bbc589a'
GROUP BY label_id
UNION ALL
SELECT 'artists' as metric, COALESCE(COUNT(artists.name)::numeric, 0) as value, label_id
FROM artists
JOIN music_labels
ON artists.label_id = music_labels.id
WHERE music_labels.owner = 'da9c6981-5382-4809-af0f-bc324bbc589a'
OR artists.label_id IS NULL
GROUP BY label_id
UNION ALL
SELECT 'releases' as metric, COUNT(releases.id) as value, releases.label as label_id
FROM releases
JOIN music_labels
ON releases.label = music_labels.id
WHERE music_labels.owner = 'da9c6981-5382-4809-af0f-bc324bbc589a'
GROUP BY releases.label;
Bazinga
01/02/2023, 3:30 PMmrboutte
01/02/2023, 4:03 PM(((jwt() -> 'user_metadata'::text) ->> 'role'::text) = 'admin'::text)
is this the correct way to check user_metadata
☝️ I want to verify the user in the jwt has user_metadata.role === 'admin'
Spoonz
01/02/2023, 4:23 PMraw_user_meta_data
column has a field updated by using event == 'USER_UPDATED
but I can't get the state change function to fire with the USER_UPDATED event type at all. I'm running an update on that column from both SQL editor and browser and nothing is detected. It picks up SIGNED_IN events when switching tabs so I'm confident my useEffect hook is correct, does anyone have an example of it working with USER_UPDATED?xyzz
01/02/2023, 5:26 PMLiaxum
01/02/2023, 5:32 PMDigitalSolomon
01/02/2023, 6:10 PMStorageException
whenever I attempt overwrite a file.
StorageException
error: Duplicate
message: The resource already exists
statusCode: 409
I have UPDATE
, SELECT
, and INSERT
storage policies for public access.
What's best way to update an image but keep the same file path?
ThanksGonza
01/02/2023, 7:00 PMHayHay
01/02/2023, 7:01 PMjson
{"code":400,"msg":"Unsupported provider: provider is not enabled"}
I've attached the changes I made to the .env file for the docker container, which I'm not 100% sure is right or not
Thanks!bro
01/02/2023, 7:23 PM<Tabs>
<Tabs.Panel id="one" label="Tab one">
Tab one content
</Tabs.Panel>
<Tabs.Panel id="two" label="Tab two">
Tab two content
</Tabs.Panel>
<Tabs.Panel id="three" label="Tab three">
Tab three content
</Tabs.Panel>
</Tabs>
what I'm trying to achieve is to change the Tabs
color to something else other than the default green.
anyone knows how to do it?Ankur63
01/02/2023, 7:58 PM