Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Light-OAuth2 issue #320

Open
narayanab16 opened this issue Jun 30, 2021 · 8 comments
Open

Light-OAuth2 issue #320

narayanab16 opened this issue Jun 30, 2021 · 8 comments

Comments

@narayanab16
Copy link

Hi,

i am unable to test , followed these two links

mariadb compose https://doc.networknt.com/tutorial/oauth/start/
try to registre client: https://doc.networknt.com/tutorial/oauth/client/
Mariadb 10.3
networknt/oauth2-XXX : 2.0.19

Client Error:
=======

[admin@centos8 ~]$ curl -k -H "Content-Type: application/json" \

-X POST -d '{"clientType":"public","clientProfile":"mobile","clientName":"AccountViewer","clientDesc":"Retail Online Banking Account Viewer","scope":"act.r act.w","redirectUri": "http://localhost:8080/authorization","ownerId":"admin"}' https://localhost:6884/oauth2/client

{"statusCode":500,"code":"ERR10010","message":"RUNTIME_EXCEPTION","description":"Unexpected runtime exception","severity":"ERROR"}[admin@centos8 ~]$

Server Error
========

oauth2-client_1 | 22:09:34.459 [XNIO-1 task-1] lvfFJgRcSQWRcusNh4Z76Q ERROR c.n.exception.ExceptionHandler handleRequest - Exception:
oauth2-client_1 | java.lang.RuntimeException: java.sql.SQLException: Trying to connect with ssl, but ssl not enabled in the server
oauth2-client_1 | at com.networknt.oauth.cache.ClientMapStore.load(ClientMapStore.java:118)
oauth2-client_1 | at com.networknt.oauth.cache.ClientMapStore.load(ClientMapStore.java:19)
oauth2-client_1 | at com.hazelcast.map.impl.MapStoreWrapper.load(MapStoreWrapper.java:165)
oauth2-client_1 | at com.hazelcast.map.impl.mapstore.writethrough.WriteThroughStore.load(WriteTh

@stevehu
Copy link
Contributor

stevehu commented Jul 4, 2021

MariaDB shares the same database driver with MySQL. MySQL docker enables SSL by default, so we have updated the driver configuration to enable SSL on the client. However, MariaDB doesn't support SSL at the moment. I think we should remove the MariaDB docker-compose from the light-docker and update the tutorial to remove the MariaDB. What do you think?

BTW, I have tried MySQL and it works. However, I have to update the client tutorial to add the host to the insert and update. The issue to update the document can be found at networknt/light-doc#272

@narayanab16
Copy link
Author

narayanab16 commented Jul 4, 2021

Hi,
I have tried before MySQL docker compose which throws null exception tried 2 times but no luck.
MariaDB - i got your answer, support not provided.

i will try to clone and test mysql- compose now, and let you know feedback.

@stevehu
Copy link
Contributor

stevehu commented Jul 4, 2021

The null exception is due to host missing in the request body. Try the updated document and it and should work.

@narayanab16
Copy link
Author

narayanab16 commented Jul 4, 2021

Where to update hostname?

Server start: https://doc.networknt.com/tutorial/oauth/start/
Client - the same compute node

Example followed here : https://doc.networknt.com/tutorial/oauth/token/
client request:

curl -k -H "Authorization: Basic f7d42348-c647-4efb-a52d-4c5787421e72:f6h1FTI8Q3-7UScPZDzfXA" -H "Content-Type: application/x-www-form-urlencoded" -X POST -d "grant_type=authorization_code&code=c0iAfPAeTk2BpiPWj-CYPQ" https://localhost:6882/oauth2/token

[admin@centos8 light-docker]$ netstat -tulpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6881 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6882 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6883 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6884 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6885 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6886 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6887 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN -
tcp6 0 0 :::2222 :::* LISTEN -
udp 0 0 127.0.0.1:323 0.0.0.0:* -

Still i get null error

@stevehu
Copy link
Contributor

stevehu commented Jul 4, 2021

You don't need to update anything. Just copy the latest curl command from the client tutorial. Looks like you are trying the token endpoint and get another exception. Let me take a look and update the document.

BTW, I have updated the doc to mark the MariaDB deprecated.
networknt/light-doc#273

@narayanab16
Copy link
Author

narayanab16 commented Jul 4, 2021

Thanks
i have tested here with mysql docker compose
Server

curl -k -H "Content-Type: application/json" -X PUT -d '{"clientDesc":"PetStore Web Server","clientId":"f7d42348-c647-4efb-a52d-4c5787421e72","clientType":"public","clientProfile":"mobile","redirectUri":"http://localhost:8080/authorization","clientName":"PetStore Web Server","scope":"petstore.r petstore.w","clientSecret":"f6h1FTI8Q3-7UScPZDzfXA","ownerId":"admin","host":"localhost"}' https://localhost:6884/oauth2/client

client

curl -k -H "Authorization: Basic f7d42348-c647-4efb-a52d-4c5787421e72:f6h1FTI8Q3-7UScPZDzfXA" -H "Content-Type: application/x-www-form-urlencoded"
-X POST -d "grant_type=authorization_code&code=c0iAfPAeTk2BpiPWj-CYPQ"
https://localhost:6882/oauth2/token

[admin@centos8 light-docker]$ curl -k -H "Authorization: Basic f7d42348-c647-4efb-a52d-4c5787421e72:f6h1FTI8Q3-7UScPZDzfXA" -H "Content-Type: application/x-www-form-urlencoded" -X POST -d "grant_type=authorization_code&code=c0iAfPAeTk2BpiPWj-CYPQ" https://localhost:6882/oauth2/token
{"statusCode":500,"code":"ERR10010","message":"RUNTIME_EXCEPTION","description":"Unexpected runtime exception","severity":"ERROR"}[admin@centos8 light-docker]

@stevehu
Copy link
Contributor

stevehu commented Jul 4, 2021

You are using the authorization code grant type without getting the authorization code. Follow the code.md before getting the token. Or just use the client credential flow.

@stevehu
Copy link
Contributor

stevehu commented Jul 4, 2021

I have updated the document to clarify the step for authorization code flow.

networknt/light-doc#274

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

No branches or pull requests

2 participants