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

Failure when pgcrypto is loaded into a schema. #6

Closed
daurnimator opened this issue Jun 28, 2017 · 3 comments · Fixed by #10
Closed

Failure when pgcrypto is loaded into a schema. #6

daurnimator opened this issue Jun 28, 2017 · 3 comments · Fixed by #10

Comments

@daurnimator
Copy link

When pgcrypto is loaded into a schema then pgjwt fails to find pgcrypto functions:

postgres=# create schema pgcrypto;
CREATE SCHEMA
postgres=# create extension pgcrypto with schema pgcrypto;
CREATE EXTENSION
postgres=# create schema pgjwt;
CREATE SCHEMA
postgres=# create extension pgjwt with schema pgjwt;
CREATE EXTENSION
postgres=# select pgjwt.sign('{}', 'foo');
ERROR:  function hmac(text, text, text) does not exist
LINE 9: SELECT pgjwt.url_encode(hmac(signables, secret, alg.id)) FRO...
                                ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
QUERY:  
WITH
  alg AS (
    SELECT CASE
      WHEN algorithm = 'HS256' THEN 'sha256'
      WHEN algorithm = 'HS384' THEN 'sha384'
      WHEN algorithm = 'HS512' THEN 'sha512'
      ELSE '' END AS id)  -- hmac throws error
SELECT pgjwt.url_encode(hmac(signables, secret, alg.id)) FROM alg;

CONTEXT:  SQL function "algorithm_sign" during inlining
SQL function "sign" during startup
@guiuprado
Copy link

I have the same issue and to adjust to

was: SELECT pgjwt.url_encode(hmac(signables, secret, alg.id)) FROM alg;

are: SELECT pgjwt.url_encode(public.hmac(signables, secret, alg.id)) FROM alg;

I'm using pg10 with a other schema with Postgrest 0.5

@michelp
Copy link
Owner

michelp commented May 31, 2018

This is likely due to a recent change made to postgrest that sets the search path for a request to only the api schema PostgREST/postgrest#1125

I'll release a fix for this that puts public back into the function paths, and add a note to the readme warning about having pgcrypto in another schema requires altering the functions.

@daurnimator
Copy link
Author

This is likely due to a recent change made to postgrest

Note that the original issue here is not postgrest related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants